Exemple #1
0
 def parse_ledger(self, filename, str = None):
     if str is None:
         str = codecs.open(filename, "r", "utf-8").read()
     f = lambda (number, line): line == ""
     lines = itertools.izip(itertools.count(1), str.split("\n"))
     try:
         transactions = [self.parse_transaction(group) for group in itersplit(f, lines)]
     except PledgerException, e:
         e.filename = filename
         raise e
Exemple #2
0
 def testItersplit(self):
     items = range(20)
     result =  [range(5), range(6, 10),
                range(11, 15), range(16, 20)]
     p = lambda x: x % 5 == 0
     self.assertEqual(result, list(util.itersplit(p, items)))