diff -r 9f7a056dbcc6 -r 2b602a1521e7 UtilitiesPython2/Tools.py --- a/UtilitiesPython2/Tools.py Fri Sep 09 09:33:19 2011 +0200 +++ b/UtilitiesPython2/Tools.py Fri Sep 09 11:54:20 2011 +0200 @@ -95,6 +95,27 @@ codestring = codestring + '\n' return codestring + + +def extractLineFlags(line, startComment="#", endComment=""): + """ + Function to extract flags starting and ending with '__' from a line comment. + @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) + @return list containing the extracted flags (list of strings) + """ + flags = [] + + pos = line.rindex(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("__"))] + return flags + # # eflag: FileType = Python2