support -e/-i & changelog entry
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
5003b935f4
commit
ab362be637
4 changed files with 25 additions and 11 deletions
13
bin/ctt
13
bin/ctt
|
@ -67,11 +67,16 @@ def parse_argv(argv, version):
|
||||||
parents=[parser['loglevel']])
|
parents=[parser['loglevel']])
|
||||||
parser['report'].set_defaults(func=Report.commandline)
|
parser['report'].set_defaults(func=Report.commandline)
|
||||||
parser['report'].add_argument("project", help="Project to report time for", nargs=1)
|
parser['report'].add_argument("project", help="Project to report time for", nargs=1)
|
||||||
parser['report'].add_argument("-s", "--start", help="Start date (default: first of last month, format: %s)" % ctt.DATEFORMAT_PLAIN,
|
parser['report'].add_argument("--sd", "--start", help="Start date (default: first of last month, format: %s)" % ctt.DATEFORMAT_PLAIN,
|
||||||
nargs=1)
|
nargs=1, dest="start")
|
||||||
parser['report'].add_argument("-e", "--end", help="End date (default: last of last month, format: %s)" % ctt.DATEFORMAT_PLAIN, nargs=1, default=None)
|
parser['report'].add_argument("--ed", "--end", help="End date (default: last of last month, format: %s)" % ctt.DATEFORMAT_PLAIN,
|
||||||
|
nargs=1, default=None, dest="end")
|
||||||
|
|
||||||
parser['report'].add_argument("-f", "--format", help="Output format (default: %s)" % ctt.REPORTFORMAT, default=ctt.REPORTFORMAT, dest="output_format")
|
parser['report'].add_argument("-e", "--regexp", help="Regular expression to match",
|
||||||
|
default=None)
|
||||||
|
parser['report'].add_argument("-i", "--ignore-case", help="Ignore case distinctions", action="store_true")
|
||||||
|
parser['report'].add_argument("-f", "--format", help="Output format (default: %s)" % ctt.REPORTFORMAT,
|
||||||
|
default=ctt.REPORTFORMAT, dest="output_format")
|
||||||
|
|
||||||
#parser['track'].add_argument("-t", "--tag", help="Add tags",
|
#parser['track'].add_argument("-t", "--tag", help="Add tags",
|
||||||
# action="store_true")
|
# action="store_true")
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
Changelog
|
Changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
0.8: 2013-04-27
|
||||||
|
* Added -e / --regexp support for filtering entries on report
|
||||||
|
* Added -i / --ignore-case support
|
||||||
|
* Renamed -s/-e to --sd / --ed (to allow -e for expression)
|
||||||
|
|
||||||
0.7:
|
0.7:
|
||||||
* Added -f / --format support for reporting
|
* Added -f / --format support for reporting
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
VERSION = "0.6"
|
VERSION = "0.8"
|
||||||
FILE_DELTA = "delta"
|
FILE_DELTA = "delta"
|
||||||
FILE_COMMENT = "comment"
|
FILE_COMMENT = "comment"
|
||||||
DATEFORMAT = "%Y-%m-%d"
|
DATEFORMAT = "%Y-%m-%d"
|
||||||
|
|
|
@ -38,19 +38,26 @@ log = logging.getLogger(__name__)
|
||||||
class Report(object):
|
class Report(object):
|
||||||
"""Create a report on tracked time"""
|
"""Create a report on tracked time"""
|
||||||
|
|
||||||
def __init__(self, project, start_date, end_date, output_format):
|
def __init__(self, project, start_date, end_date,
|
||||||
|
output_format, regexp, ignore_case):
|
||||||
|
|
||||||
self.project = project
|
self.project = project
|
||||||
self.project_dir = ctt.project_dir(self.project)
|
self.project_dir = ctt.project_dir(self.project)
|
||||||
|
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.regexp = regexp
|
||||||
|
|
||||||
|
if ignore_case:
|
||||||
|
self.search_flags = re.IGNORECASE
|
||||||
|
else:
|
||||||
|
self.search_flags = 0
|
||||||
|
|
||||||
self._init_date(start_date, end_date)
|
self._init_date(start_date, end_date)
|
||||||
self._init_report_db()
|
self._init_report_db()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def commandline(cls, args):
|
def commandline(cls, args):
|
||||||
report = cls(args.project[0], args.start, args.end, args.output_format)
|
report = cls(args.project[0], args.start, args.end, args.output_format, args.regexp, args.ignore_case)
|
||||||
report.report()
|
report.report()
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,9 +102,6 @@ class Report(object):
|
||||||
if not os.path.isdir(self.project_dir):
|
if not os.path.isdir(self.project_dir):
|
||||||
raise ctt.Error("Project does not exist: %s" % (self.project))
|
raise ctt.Error("Project does not exist: %s" % (self.project))
|
||||||
|
|
||||||
# self.regexp = "^rails19"
|
|
||||||
self.regexp = None
|
|
||||||
|
|
||||||
self._report_db = {}
|
self._report_db = {}
|
||||||
for dirname in os.listdir(self.project_dir):
|
for dirname in os.listdir(self.project_dir):
|
||||||
dir_datetime = datetime.datetime.strptime(dirname, ctt.DISKFORMAT)
|
dir_datetime = datetime.datetime.strptime(dirname, ctt.DISKFORMAT)
|
||||||
|
@ -112,7 +116,7 @@ class Report(object):
|
||||||
comment = fd.read().rstrip('\n')
|
comment = fd.read().rstrip('\n')
|
||||||
|
|
||||||
# If regular expression given, but not matching, skip entry
|
# If regular expression given, but not matching, skip entry
|
||||||
if self.regexp and not re.search(self.regexp, comment):
|
if self.regexp and not re.search(self.regexp, comment, self.search_flags):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue