Skip to content

Commit

Permalink
Alternate entry format optionally allowing descriptions ignored in gr…
Browse files Browse the repository at this point in the history
…ouping
  • Loading branch information
Peter Hahn committed May 2, 2020
1 parent 9143f8e commit 6f7e8fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gtimelog/timelog.py
Expand Up @@ -250,6 +250,11 @@ def split_category(entry):
"""
if ': ' in entry:
cat, tsk = entry.split(': ', 1)
t, _, c = cat.partition('@')
if c and t:
# if category string can be further partitioned into non empty strings by '@'
# use 1st as task and 2nd as category
cat, tsk = c, t
return cat.strip(), tsk.strip()
elif entry.endswith(':'):
return entry.partition(':')[0].strip(), ''
Expand Down Expand Up @@ -284,6 +289,10 @@ def grouped_entries(self, skip_first=True):
work = {}
slack = {}
for start, stop, duration, tags, entry in self.all_entries():
cat, task = self.split_category(entry)
entry = task if task is not None else ''
if cat:
entry = cat + ': ' + entry
if skip_first:
# XXX: in case of for multi-day windows, this should skip
# the 1st entry of each day
Expand Down

0 comments on commit 6f7e8fe

Please sign in to comment.