catch invalid time entries
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
4de600713a
commit
d0cf603675
3 changed files with 15 additions and 6 deletions
|
@ -4,13 +4,14 @@ Changelog
|
||||||
* Changes are always commented with their author in (braces)
|
* Changes are always commented with their author in (braces)
|
||||||
* Exception: No braces means author == Nico Schottelius
|
* Exception: No braces means author == Nico Schottelius
|
||||||
|
|
||||||
1.0:
|
1.0: 2014-07-01
|
||||||
* Added installer (Oz Nahum)
|
* Added installer (Oz Nahum)
|
||||||
* Bugfix in listprojects (Oz Nahum)
|
* Bugfix in listprojects (Oz Nahum)
|
||||||
* Allow ctt to run from checkout and installation path
|
* Allow ctt to run from checkout and installation path
|
||||||
* Correct license indication in setup.py (Davide Riccardo Caliendo)
|
* Correct license indication in setup.py (Davide Riccardo Caliendo)
|
||||||
* Added license and manifest files (Davide Riccardo Caliendo)
|
* Added license and manifest files (Davide Riccardo Caliendo)
|
||||||
* Added bash completion script (Davide Riccardo Caliendo)
|
* Added bash completion script (Davide Riccardo Caliendo)
|
||||||
|
* Report an error on invalid time entries
|
||||||
|
|
||||||
|
|
||||||
0.9: 2013-04-29
|
0.9: 2013-04-29
|
||||||
|
|
|
@ -70,5 +70,4 @@ def project_dir(project):
|
||||||
|
|
||||||
return project_dir
|
return project_dir
|
||||||
|
|
||||||
def list_projects(ctt_dir):
|
|
||||||
return os.listdir(ctt_dir)
|
return os.listdir(ctt_dir)
|
||||||
|
|
|
@ -117,7 +117,12 @@ class Report(object):
|
||||||
|
|
||||||
self._report_db = {}
|
self._report_db = {}
|
||||||
for dirname in os.listdir(self.project_dir):
|
for dirname in os.listdir(self.project_dir):
|
||||||
|
log.debug("Dirname: %s" % dirname)
|
||||||
|
try:
|
||||||
dir_datetime = datetime.datetime.strptime(dirname, ctt.DISKFORMAT)
|
dir_datetime = datetime.datetime.strptime(dirname, ctt.DISKFORMAT)
|
||||||
|
except ValueError:
|
||||||
|
raise ctt.Error("Invalid time entry {entry} for project {project}, aborting!".format(entry=dirname, project=self.project))
|
||||||
|
|
||||||
if dir_datetime >= self.start_date and dir_datetime <= self.end_date:
|
if dir_datetime >= self.start_date and dir_datetime <= self.end_date:
|
||||||
filename = os.path.join(self.project_dir, dirname, ctt.FILE_DELTA)
|
filename = os.path.join(self.project_dir, dirname, ctt.FILE_DELTA)
|
||||||
comment_filename = os.path.join(self.project_dir, dirname, ctt.FILE_COMMENT)
|
comment_filename = os.path.join(self.project_dir, dirname, ctt.FILE_COMMENT)
|
||||||
|
@ -182,12 +187,16 @@ class Report(object):
|
||||||
entry = self._report_db[time]
|
entry = self._report_db[time]
|
||||||
report = {}
|
report = {}
|
||||||
|
|
||||||
report['start_datetime'] = datetime.datetime.strptime(time, ctt.DATETIMEFORMAT)
|
start_datetime = datetime.datetime.strptime(time, ctt.DATETIMEFORMAT)
|
||||||
|
delta = datetime.timedelta(seconds=int(float(entry['delta'])))
|
||||||
|
end_datetime = (start_datetime + delta).replace(microsecond = 0)
|
||||||
|
|
||||||
|
report['start_datetime'] = start_datetime.strftime(ctt.DATETIMEFORMAT)
|
||||||
|
report['end_datetime'] = end_datetime.strftime(ctt.DATETIMEFORMAT)
|
||||||
|
|
||||||
|
report['delta'] = delta
|
||||||
report['delta_seconds'] = int(float(entry['delta']))
|
report['delta_seconds'] = int(float(entry['delta']))
|
||||||
report['delta_minutes'] = int(report['delta_seconds']/60)
|
report['delta_minutes'] = int(report['delta_seconds']/60)
|
||||||
report['delta'] = datetime.timedelta(seconds=int(float(entry['delta'])))
|
|
||||||
report['end_datetime'] = (report['start_datetime'] + report['delta']).replace(microsecond = 0)
|
|
||||||
|
|
||||||
if 'comment' in entry:
|
if 'comment' in entry:
|
||||||
report['comment'] = entry['comment']
|
report['comment'] = entry['comment']
|
||||||
|
|
Loading…
Reference in a new issue