helper_search pylint fixes

This commit is contained in:
lakshyacis 2019-10-09 17:33:51 +05:30
parent 9041b8f644
commit d5f541a2ab
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -10,13 +10,15 @@ except ImportError:
def search_translate(context, text): def search_translate(context, text):
"""Translation wrapper"""
if haveQt: if haveQt:
return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text)
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):
"""Perform a search in mailbox tables"""
# pylint: disable=too-many-arguments, too-many-branches
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"):
@ -64,7 +66,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
sqlArguments.append(what) sqlArguments.append(what)
if unreadOnly: if unreadOnly:
sqlStatementParts.append("read = 0") sqlStatementParts.append("read = 0")
if len(sqlStatementParts) > 0: if sqlStatementParts:
sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts) sqlStatementBase += "WHERE " + " AND ".join(sqlStatementParts)
if folder == "sent": if folder == "sent":
sqlStatementBase += " ORDER BY lastactiontime" sqlStatementBase += " ORDER BY lastactiontime"
@ -72,6 +74,8 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
def check_match(toAddress, fromAddress, subject, message, where=None, what=None): def check_match(toAddress, fromAddress, subject, message, where=None, what=None):
"""Check if a single message matches a filter (used when new messages are added to messagelists)"""
# pylint: disable=too-many-arguments
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():