Support multiple mapping files in kimai sync

This commit is contained in:
3wc 2023-09-06 12:00:16 +02:00
parent f858d4a5f0
commit 98aee02ee8

View File

@ -444,10 +444,18 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None):
kimai_api_url = 'https://kimai.autonomic.zone/api' kimai_api_url = 'https://kimai.autonomic.zone/api'
if mapping_path is None: if type(mapping_path) == tuple:
mapping_path = HAMSTER_DIR / 'mapping.kimai.csv' mapping_files = []
mapping_file = _get_kimai_mapping_file(mapping_path) for mapping_path_item in mapping_path:
mapping_reader = csv.reader(mapping_file) mapping_file = _get_kimai_mapping_file(mapping_path_item)
next(mapping_file)
mapping_files.append(mapping_file)
mapping_reader = csv.reader(chain(*mapping_files))
else:
if mapping_path is None:
mapping_path = HAMSTER_DIR / 'mapping.kimai.csv'
mapping_file = _get_kimai_mapping_file(mapping_path)
mapping_reader = csv.reader(mapping_file)
next(mapping_reader) next(mapping_reader)
@ -636,7 +644,8 @@ def _import(username, mapping_path=None, output=None, category_search=None, afte
"Exported", "Exported",
"Tags", "Tags",
"HourlyRate", "HourlyRate",
"FixedRate" "FixedRate",
"InternalRate"
]) ])
for fact in results: for fact in results: