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 1, 2020
1 parent 2988cab commit ee6f46f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gtimelog/main.py
Expand Up @@ -1342,12 +1342,12 @@ def on_tasks_file_changed(self, monitor, file, other_file, event_type):
GLib.timeout_add_seconds(1, self.check_reload_tasks)

def check_reload(self):
if self.timelog.check_reload():
if self.timelog and self.timelog.check_reload():
self.notify('timelog')
self.tick(True)

def check_reload_tasks(self):
if self.tasks.check_reload():
if self.tasks and self.tasks.check_reload():
self.notify('tasks')

def enable_add_entry(self):
Expand Down
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 ee6f46f

Please sign in to comment.