From 98aee02ee8ac5e252e9083a1a0206b2c7c3b6c61 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Wed, 6 Sep 2023 12:00:16 +0200 Subject: [PATCH] Support multiple mapping files in `kimai sync` --- hamstertools/__init__.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hamstertools/__init__.py b/hamstertools/__init__.py index 6a8b83d..f65890f 100755 --- a/hamstertools/__init__.py +++ b/hamstertools/__init__.py @@ -444,10 +444,18 @@ def sync(username, api_key, just_errors, ignore_activities, mapping_path=None): kimai_api_url = 'https://kimai.autonomic.zone/api' - 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) + if type(mapping_path) == tuple: + mapping_files = [] + for mapping_path_item in mapping_path: + 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) @@ -636,7 +644,8 @@ def _import(username, mapping_path=None, output=None, category_search=None, afte "Exported", "Tags", "HourlyRate", - "FixedRate" + "FixedRate", + "InternalRate" ]) for fact in results: