Skip to content

Commit

Permalink
Propose alternate entry format optionally allowing descriptions ignor…
Browse files Browse the repository at this point in the history
…ed in grouping
  • Loading branch information
Peter Hahn committed Apr 30, 2020
1 parent 52aa8f2 commit 2b051b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 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
11 changes: 10 additions & 1 deletion src/gtimelog/timelog.py
Expand Up @@ -249,7 +249,13 @@ def split_category(entry):
Return a tuple (category, task).
"""
if ': ' in entry:
return tuple(entry.split(': ', 1))
cat, task = 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, task = c, t
return cat, task
elif entry.endswith(':'):
return entry.partition(':')[0], ''
else:
Expand Down Expand Up @@ -283,6 +289,9 @@ 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 or ''
entry = cat and cat + ': ' + entry or 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 2b051b1

Please sign in to comment.