Example #1
0
 def parse_file(cls, filename):
     rcps = cls()
     with open(filename) as f:
         for (lineno, line) in enumerate(f, 1):
             line = line.rstrip("\r\n")
             if line.startswith("#") or line.strip() == "":
                 continue
             try:
                 recipe = Recipe.parse_line(line)
             except ParseError:
                 raise Exception("Could not parse recipe on line %d." %
                                 (lineno))
             rcps.add(recipe)
     return rcps