From 8038bf4e264923ec79a0f1ebe8fdc04b2e3a31ff Mon Sep 17 00:00:00 2001 From: codingforfun Date: Thu, 3 Sep 2015 23:01:15 +0200 Subject: [PATCH] Move options for merging and rounding to profile. Commandline still may override profile settings. --- hamster-export | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/hamster-export b/hamster-export index 39bae6c..1aed849 100755 --- a/hamster-export +++ b/hamster-export @@ -272,6 +272,11 @@ class ActiveCollab(Profile): def process(self, timesheet, **kwargs): timesheet = self.filter_timesheet(timesheet) + + if self._options.get('short'): + timesheet.shorten() + timesheet.round_up(parse_round(self._options.get('round'))) + timesheet = ActiveCollab.edit_timesheet(timesheet) timesheet.check_activities(self._activities.values()) @@ -336,6 +341,11 @@ class CSV(Profile): def process(self, timesheet, **kwargs): timesheet = self.filter_timesheet(timesheet) + + if self._options.get('short'): + timesheet.shorten() + timesheet.round_up(parse_round(self._options.get('round'))) + timesheet = ActiveCollab.edit_timesheet(timesheet) timesheet.check_activities(self._activities.values()) @@ -363,12 +373,21 @@ def load_profile(config_files, args, activities): exit('No such profile:', args.profile) profile = None format_ = config.get(section, 'format') + + options = dict(config.items(section)) + + if args.round: + options.update(round=args.round) + + if args.short: + options.update(short=args.short) + if format_ == 'activecollab': profile = ActiveCollab(args.profile, config.get(section, 'url'), config.get(section, 'api_key'), - dict(config.items(section))) + options) elif format_ == 'csv': - profile = CSV(args.profile, args.filename, dict(config.items(section))) + profile = CSV(args.profile, args.filename, options) else: exit('Not supported format:', format_)