diff --git a/lib/aslint/python/python_checkers.py b/lib/aslint/python/python_checkers.py index 9a901651b8305ff344cc1e526f759b802a3e72ac..7698ece700b661660913185de992bdfb6662b7f1 100644 --- a/lib/aslint/python/python_checkers.py +++ b/lib/aslint/python/python_checkers.py @@ -198,12 +198,34 @@ class ObsoleteSdj(FileContentCat, TextMsg): apply_ctxt = CheckContext(reponame=["src"], branch="main") search = search_msg(r"(?P<main>\w+\.sdj(?:\.\w+)?)", ignore_case=False) + class ObsoleteGetvectjev(FileContentCat, TextMsg): """Obsolete use of getvectjev or getcolljev""" id = "C4015" search = search_msg(r"(?P<main>(getvectjev|getcolljev))", ignore_case=False) + +class MultiLinesUtmess(FileContentCat, GenericMsg): + """Message id not found on the same line (use a dict for args)""" + + id = "C4501" + + def search(self, txt): + """Check for UTMESS without message id""" + if "def format_exception" in txt: + return [] + if "class MESSAGE_LOGGER" in txt: + return [] + re_utm = re.compile(r"(?P<line>(?:UTMESS|GetText|message_exception)\s*\(.*)", re.M) + re_id = re.compile(r"(UTMESS|GetText|message_exception)\s*\(.*_", re.I) + err = [] + for mat in re_utm.finditer(txt): + if not re_id.search(mat.group("line")): + err.append(f": {mat.group('line')}") + return err + + class ReformatSource(FilenameCat, COMM.ReformatPy): """Reformat Python source"""