return text
else:
return text[:length - len(_ASCII_ELLIPSIS)] + _ASCII_ELLIPSIS
+
+
+def FilterEmptyLinesAndComments(text):
+ """Filters empty lines and comments from a line-based string.
+
+ Whitespace is also removed from the beginning and end of all lines.
+
+ @type text: string
+ @param text: Input string
+ @rtype: list
+
+ """
+ return [line for line in map(lambda s: s.strip(), text.splitlines())
+ # Ignore empty lines and comments
+ if line and not line.startswith("#")]