home
·
contact
·
privacy
projects
/
plomledger
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c4ca973
)
Fix handling of erroneous date fields.
master
author
Christian Heller
<c.heller@plomlompom.de>
Wed, 29 Jan 2025 02:41:56 +0000
(
03:41
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Wed, 29 Jan 2025 02:41:56 +0000
(
03:41
+0100)
ledger.py
patch
|
blob
|
history
diff --git
a/ledger.py
b/ledger.py
index 0c6ed5eccd78541a3808b74c113a489a8b15fe35..ebb188f0c040a30dec11aaae34b5e95dbdc77060 100755
(executable)
--- a/
ledger.py
+++ b/
ledger.py
@@
-144,23
+144,17
@@
class IntroLine(BookingLine):
def __init__(self, booking: 'Booking', code: str) -> None:
super().__init__(booking)
def __init__(self, booking: 'Booking', code: str) -> None:
super().__init__(booking)
- self.date = '#'
- self.target = ''
if code[0].isspace():
self.errors += ['intro line indented']
toks = code.lstrip().split(maxsplit=1)
if code[0].isspace():
self.errors += ['intro line indented']
toks = code.lstrip().split(maxsplit=1)
- if len(toks) != 2:
+ self.date = toks[0]
+ self.target = toks[1] if len(toks) > 1 else ''
+ if len(toks) == 1:
self.errors += ['illegal number of tokens']
self.errors += ['illegal number of tokens']
- elif len(toks) < 1:
- return
- else:
- self.target = toks[1]
try:
try:
- dt_date.fromisoformat(
toks[0]
)
+ dt_date.fromisoformat(
self.date
)
except ValueError:
except ValueError:
- self.errors += [f'not properly formatted legal date: {toks[0]}']
- else:
- self.date = toks[0]
+ self.errors += [f'not properly formatted legal date: {self.date}']
@property
def as_dict(self) -> dict:
@property
def as_dict(self) -> dict: