Skip to content

Commit

Permalink
W bring parse tag list to modify tags
Browse files Browse the repository at this point in the history
  • Loading branch information
diegogangl committed Jul 10, 2022
1 parent b4405ef commit 4f07c7a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion GTG/gtk/browser/modify_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ def __init__(self, tag_completion, app):
self.last_tag_entry = _("NewTag")
self.last_apply_to_subtasks = False


def parse_tag_list(self, text):
""" Parse a line of a list of tasks. User can specify if the tag is
positive or not by prepending '!'.
@param text: string entry from user
@return: list of tupples (tag, is_positive)
"""

result = []
for tag in text.split():
if tag.startswith('!'):
tag = tag[1:]
is_positive = False
else:
is_positive = True

result.append((tag, is_positive))
return result


def modify_tags(self, tasks):
""" Show and run dialog for selected tasks """

Expand All @@ -71,7 +92,7 @@ def on_response(self, widget, response):
def apply_changes(self):
""" Apply changes """

tags = parse_tag_list(self._tag_entry.get_text())
tags = self.parse_tag_list(self._tag_entry.get_text())

# If the checkbox is checked, find all subtasks
if self._apply_to_subtasks_check.get_active():
Expand Down

0 comments on commit 4f07c7a

Please sign in to comment.