From e422738085c9c1211a62aaa64468e586063c2a06 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 3 Jul 2018 10:21:52 +0200 Subject: [PATCH] Ignore, warn and continue in case of invalid delta --- .gitignore | 1 + changelog | 1 + lib/ctt/report.py | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2f4a08b..81c1a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ lib/ctt/__pycache__/ # -vim .*.swp +.ropeproject # Manpages *.1 diff --git a/changelog b/changelog index 3374a7f..386e3ef 100644 --- a/changelog +++ b/changelog @@ -3,6 +3,7 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius + * Ignore, warn and continue in case of invalid delta (Darko Poljak) 1.1: 2017-02-16 * Ignore non matching patterns for report command (Darko Poljak) diff --git a/lib/ctt/report.py b/lib/ctt/report.py index 3a6b088..c88f8a6 100755 --- a/lib/ctt/report.py +++ b/lib/ctt/report.py @@ -229,8 +229,13 @@ class Report(object): for entry in self._report_db.values(): delta = entry['delta'] log.debug("Adding %s to %s time..." % (delta, count)) - count = count + float(delta) - + try: + count = count + float(delta) + except ValueError: + log.warning("Invalid delta in entry {entry} for project " + "{project}, skipping for total time.".format( + entry=entry, project=self.project)) + continue return count def _get_report_entry(self, time, entry): @@ -261,7 +266,13 @@ class Report(object): time_keys = self._report_db.keys() for time in time_keys: entry = self._report_db[time] - report = self._get_report_entry(time, entry) + try: + report = self._get_report_entry(time, entry) + except ValueError: + log.warning("Invalid delta in entry {entry} for project " + "{project}, skipping for report.".format( + entry=entry, project=self.project)) + continue if time not in entries: entries[time] = [report] else: