helper_search flake8 fixes

This commit is contained in:
lakshyacis 2019-10-09 16:30:12 +05:30
parent 28cfe78e67
commit 9041b8f644
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -1,5 +1,6 @@
"""Additional SQL helper for searching messages""" """Additional SQL helper for searching messages"""
from helper_sql import *
from helper_sql import sqlQuery
try: try:
from PyQt4 import QtGui from PyQt4 import QtGui
@ -7,13 +8,15 @@ try:
except ImportError: except ImportError:
haveQt = False haveQt = False
def search_translate (context, text):
def search_translate(context, text):
if haveQt: if haveQt:
return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text)
else: else:
return text.lower() return text.lower()
def search_sql(xAddress = "toaddress", account = None, folder = "inbox", where = None, what = None, unreadOnly = False):
def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, what=None, unreadOnly=False):
if what is not None and what != "": if what is not None and what != "":
what = "%" + what + "%" what = "%" + what + "%"
if where == search_translate("MainWindow", "To"): if where == search_translate("MainWindow", "To"):
@ -31,7 +34,7 @@ def search_sql(xAddress = "toaddress", account = None, folder = "inbox", where =
if folder == "sent": if folder == "sent":
sqlStatementBase = ''' sqlStatementBase = '''
SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime SELECT toaddress, fromaddress, subject, status, ackdata, lastactiontime
FROM sent ''' FROM sent '''
else: else:
sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read sqlStatementBase = '''SELECT folder, msgid, toaddress, fromaddress, subject, received, read
@ -67,7 +70,8 @@ def search_sql(xAddress = "toaddress", account = None, folder = "inbox", where =
sqlStatementBase += " ORDER BY lastactiontime" sqlStatementBase += " ORDER BY lastactiontime"
return sqlQuery(sqlStatementBase, sqlArguments) return sqlQuery(sqlStatementBase, sqlArguments)
def check_match(toAddress, fromAddress, subject, message, where = None, what = None):
def check_match(toAddress, fromAddress, subject, message, where=None, what=None):
if what is not None and what != "": if what is not None and what != "":
if where in (search_translate("MainWindow", "To"), search_translate("MainWindow", "All")): if where in (search_translate("MainWindow", "To"), search_translate("MainWindow", "All")):
if what.lower() not in toAddress.lower(): if what.lower() not in toAddress.lower():