Skip to content

Commit

Permalink
helpers: Remove 'none_category' argument on serialize_activity
Browse files Browse the repository at this point in the history
  • Loading branch information
elbenfreund committed May 4, 2018
1 parent fa8057d commit a80f604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 2 additions & 8 deletions hamster_gtk/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,30 +197,24 @@ def get_recent_activities(controller, start, end):
return OrderedSet(recent_activities)


def serialize_activity(activity, separator='@', none_category='not categorized'):
def serialize_activity(activity, separator='@'):
"""
Provide a serialized string version of an activity.
Args:
activity (Activity): ``Activity`` instance to serialize.
separator (str, optional): ``string`` used to separate ``activity.name`` and
``category.name``. The separator will be omitted if ``none_category=''`` and
``category.name``. The separator will be omitted if
``activity.category=None``. Defaults to ``@``.
none_category (str, optional): ``string`` to represent the 'lack of a category' for an
activity instance. Defaults to ``not categorized``.
Returns:
str: A string representation of the passed activity.
"""
if not separator:
raise ValueError(_("No valid separator has been provided."))
if not none_category and none_category is not '':
raise ValueError(_("No valid text for 'none_category' has been provided."))

if activity.category:
category_text = activity.category.name
else:
category_text = none_category

if category_text:
result = '{activity_text}{separator}{category_text}'.format(activity_text=activity.name,
Expand Down
6 changes: 3 additions & 3 deletions hamster_gtk/tracking/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def add_row_widgets(row_index, activity):
"""
def get_label(activity):
"""Label representing the activity/category combination."""
label = Gtk.Label(helpers.serialize_activity(activity, none_category=''))
label = Gtk.Label(helpers.serialize_activity(activity))
label.set_halign(Gtk.Align.START)
return label

Expand All @@ -335,14 +335,14 @@ def get_copy_button(activity):
actually starting the tracking.
"""
button = Gtk.Button('Copy')
activity = helpers.serialize_activity(activity, none_category='')
activity = helpers.serialize_activity(activity)
button.connect('clicked', self._on_copy_button, activity)
return button

def get_start_button(activity):
"""A button that will start a new ongoing fact based on that activity."""
button = Gtk.Button('Start')
activity = helpers.serialize_activity(activity, none_category='')
activity = helpers.serialize_activity(activity)
button.connect('clicked', self._on_start_button, activity)
return button

Expand Down

0 comments on commit a80f604

Please sign in to comment.