summaryrefslogtreecommitdiff
path: root/transaction_details.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2017-11-10 10:02:43 +0100
committerYves Fischer <yvesf-git@xapek.org>2017-11-10 10:02:43 +0100
commit7b41c5dc809159028566367fbf1f60df67eba1cb (patch)
tree25e9fb64a046cdbb753ac979228d3ce8b4daf748 /transaction_details.py
parenta003cf9f8caf45a3792793d2a58ae6f8f71cfc15 (diff)
downloadfinanzstatus-7b41c5dc809159028566367fbf1f60df67eba1cb.tar.gz
finanzstatus-7b41c5dc809159028566367fbf1f60df67eba1cb.zip
improve transaction details parsing
Diffstat (limited to 'transaction_details.py')
-rw-r--r--transaction_details.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/transaction_details.py b/transaction_details.py
index a7ecf6c..dec0ee7 100644
--- a/transaction_details.py
+++ b/transaction_details.py
@@ -40,21 +40,12 @@ VERWENDUNGSZWECK_KEYS = {
def parse_transaction_details(details):
detail_str = ''.join(d.strip() for d in details.splitlines())
- result = {}
- for key, value in DETAIL_KEYS.items():
- result[value] = None
- for key, value in VERWENDUNGSZWECK_KEYS.items():
- result[value] = None
+ detail_str = detail_str[3:]
+ result = dict(map(lambda k: [k,None], DETAIL_KEYS.values()))
+ result.update(dict(map(lambda k: [k,None], VERWENDUNGSZWECK_KEYS.values())))
pre_result = {}
- segment = ''
- segment_type = ''
- for index, char in enumerate(detail_str):
- if char != '?':
- segment += char
- continue
- pre_result[segment_type] = segment if not segment_type else segment[2:]
- segment_type = detail_str[index+1] + detail_str[index+2]
- segment = ''
+ for segment in detail_str.split('?'):
+ pre_result[segment[0:2]] = segment[2:]
for key, value in pre_result.items():
if key in DETAIL_KEYS:
result[DETAIL_KEYS[key]] = value