Add support for comments (after tracking)

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-08-28 17:23:24 +02:00
parent 58a8924811
commit 6d827c1dcc
2 changed files with 15 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import os.path
VERSION = "0.1" VERSION = "0.1"
FILE_DELTA = "delta" FILE_DELTA = "delta"
FILE_COMMENT = "comment"
DATEFORMAT = "%Y-%m-%d" DATEFORMAT = "%Y-%m-%d"
DATEFORMAT_PLAIN= DATEFORMAT.replace("%","") DATEFORMAT_PLAIN= DATEFORMAT.replace("%","")
DATETIMEFORMAT = "%Y-%m-%d-%H%M" DATETIMEFORMAT = "%Y-%m-%d-%H%M"

View file

@ -37,6 +37,7 @@ class Tracker:
self.project_dir = ctt.project_dir(project) self.project_dir = ctt.project_dir(project)
self._tracked_time = False self._tracked_time = False
self.comment = None
# Setup default values # Setup default values
try: try:
@ -60,9 +61,17 @@ class Tracker:
def commandline(cls, args): def commandline(cls, args):
tracker = cls(args.project[0], args.start, args.end, args.comment) tracker = cls(args.project[0], args.start, args.end, args.comment)
tracker.track_time() tracker.track_time()
if args.comment:
tracker.record_comment()
tracker.write_time() tracker.write_time()
log.info(tracker.delta()) log.info(tracker.delta())
def record_comment(self):
"""Record a comment for tracked data"""
self.comment = input("Comment: ")
# Track time and return information from tracking # Track time and return information from tracking
def track_time(self): def track_time(self):
"""Track time, if necessary""" """Track time, if necessary"""
@ -105,6 +114,11 @@ class Tracker:
with open(filename, "w") as fd: with open(filename, "w") as fd:
fd.write("%s\n" % self.delta()) fd.write("%s\n" % self.delta())
if self.comment:
filename = os.path.join(time_dir, ctt.FILE_COMMENT)
with open(filename, "w") as fd:
fd.write("%s\n" % self.comment)
def delta(self, in_seconds=True): def delta(self, in_seconds=True):
"""Return time delta - empty (==0) if not tracked""" """Return time delta - empty (==0) if not tracked"""