diff options
Diffstat (limited to 'transaction_details.py')
-rw-r--r-- | transaction_details.py | 19 |
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 |