- commit
- 926db4475d8a41e29c8072295182d3a3250a0069
- parent
- b765bbabf0f0702dc4dc0496faecfac865ddd30d
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-02-25 14:48
refactor: rm ParseError line number where inaccurate anyway because empty lines were removed already
Diffstat
| M | vtimelog | 28 | ++++++++-------------------- |
1 files changed, 8 insertions, 20 deletions
diff --git a/vtimelog b/vtimelog
@@ -30,15 +30,6 @@ def pairwise(items): 30 30 yield items[i], items[i + 1] 31 31 32 3233 -1 class ParseError(Exception):34 -1 def __init__(self, line, msg=''):35 -1 self.line = line36 -1 self.msg = msg37 -138 -1 def __str__(self):39 -1 return 'ParseError in line %i: %s' % (self.line, self.msg)40 -141 -142 33 class LazyTuple(tuple): 43 34 def __init__(self, src): 44 35 self._src = tuple(src) @@ -64,17 +55,14 @@ class LazyTuple(tuple): 64 55 65 56 class LazyTimelog(LazyTuple): 66 57 def parse(self, i):67 -1 try:68 -1 s = self._src[i]69 -1 if s == '':70 -1 return EMPTY_LINE71 -1 dt, comment = s.split(': ', 1)72 -1 return {73 -1 'dt': datetime.strptime(dt, DT_FORMAT),74 -1 'comment': comment75 -1 }76 -1 except Exception as e:77 -1 raise ParseError(i, str(e))-1 58 s = self._src[i] -1 59 if s == '': -1 60 return EMPTY_LINE -1 61 dt, comment = s.split(': ', 1) -1 62 return { -1 63 'dt': datetime.strptime(dt, DT_FORMAT), -1 64 'comment': comment -1 65 } 78 66 79 67 80 68 def datetime_add(dt, years=0, months=0, weeks=0, days=0, hours=0, minutes=0,