diff -r dab20c39f08c -r 0e5421d679e7 Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py --- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py Tue Mar 07 18:42:41 2017 +0100 +++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py Tue Mar 07 18:46:09 2017 +0100 @@ -65,7 +65,7 @@ return codestring -def extractLineFlags(line, startComment="#", endComment=""): +def extractLineFlags(line, startComment="#", endComment="", flagsLine=False): """ Function to extract flags starting and ending with '__' from a line comment. @@ -73,17 +73,22 @@ @param line line to extract flags from (string) @keyparam startComment string identifying the start of the comment (string) @keyparam endComment string identifying the end of a comment (string) + @keyparam flagsLine flag indicating to check for a flags only line (bool) @return list containing the extracted flags (list of strings) """ flags = [] - pos = line.rfind(startComment) - if pos >= 0: - comment = line[pos + len(startComment):].strip() - if endComment: - comment = comment.replace("endComment", "") - flags = [f.strip() for f in comment.split() - if (f.startswith("__") and f.endswith("__"))] + if not flagsLine or ( + flagsLine and line.strip().startswith(startComment)): + pos = line.rfind(startComment) + if pos >= 0: + comment = line[pos + len(startComment):].strip() + if endComment: + endPos = line.rfind(endComment) + if endPos >= 0: + comment = comment[:endPos] + flags = [f.strip() for f in comment.split() + if (f.startswith("__") and f.endswith("__"))] return flags @@ -282,8 +287,13 @@ continue _fn, lineno, col, message, msg_args = warning.getMessageData() - if "__IGNORE_WARNING__" not in extractLineFlags( - lines[lineno - 1].strip()): + lineFlags = extractLineFlags(lines[lineno - 1].strip()) + try: + lineFlags += extractLineFlags(lines[lineno].strip(), + flagsLine=True) + except IndexError: + pass + if "__IGNORE_WARNING__" not in lineFlags: results.append((_fn, lineno, col, "", message, msg_args)) except SyntaxError as err: if err.text.strip():