"""comments.py

This module provides files for working with Extracto data files.

Functions:
remove        Remove the comments from a line.
remove_many   Remove the comments from many lines.

"""
import mx.TextTools as TT

def remove(line, comment_char="#"):
    index = TT.find(line, comment_char)
    if index == -1:
        return line
    return line[:index].rstrip()

def remove_many(lines):
    """remove_many(lines) -> lines"""
    lines = map(remove, lines)
    lines = filter(None, lines)          # no blank lines
    return lines
