Commit 8ed10461 authored by Darko Poljak's avatar Darko Poljak

Ignore non matching patterns for report command.

Non matching datetime pattern directory entries are skipped.
parent 03fcffb3
......@@ -5,6 +5,7 @@ Changelog
* Exception: No braces means author == Nico Schottelius
* Ignore non matching patterns for report command (Darko Poljak)
* Added -s, --summary option (Darko Poljak)
* No args error (Darko Poljak)
* Report project name as file path basename (Darko Poljak)
......@@ -42,7 +42,7 @@ log = logging.getLogger(__name__)
class Report(object):
"""Create a report on tracked time"""
def __init__(self, project, start_date, end_date,
def __init__(self, project, start_date, end_date,
output_format, regexp, ignore_case):
self.project = project
......@@ -154,7 +154,7 @@ class Report(object):
self.end_date = self.end_date.replace(hour=23,minute=59,second=59)
if self.start_date >= self.end_date:
raise ctt.Error("End date must be after start date (%s >= %s)" %
raise ctt.Error("End date must be after start date (%s >= %s)" %
(self.start_date, self.end_date))
def _init_report_db(self):
......@@ -169,7 +169,8 @@ class Report(object):
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))
log.warning("Invalid time entry {entry} for project {project}, skipping.".format(entry=dirname, project=self.project))
if dir_datetime >= self.start_date and dir_datetime <= self.end_date:
filename = os.path.join(self.project_dir, dirname, ctt.FILE_DELTA)
......@@ -180,7 +181,7 @@ class Report(object):
if os.path.exists(comment_filename):
with open(comment_filename, "r") as fd:
comment ='\n')
# If regular expression given, but not matching, skip entry
if self.regexp and not, comment, self.search_flags):
......@@ -205,7 +206,7 @@ class Report(object):
def summary(total_time):
hours, minutes, seconds = ctt.user_timedelta(total_time)
hours, minutes, seconds = ctt.user_timedelta(total_time)
print("Total time tracked: %sh %sm %ss." %
(hours, minutes, seconds))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment