From a80f604d75c088c93e2f624a356c4f07be900bee Mon Sep 17 00:00:00 2001 From: Eric Goller Date: Fri, 4 May 2018 16:31:16 +0200 Subject: [PATCH] helpers: Remove 'none_category' argument on serialize_activity --- hamster_gtk/helpers.py | 10 ++-------- hamster_gtk/tracking/screens.py | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/hamster_gtk/helpers.py b/hamster_gtk/helpers.py index 0c4dfac4..8492d136 100644 --- a/hamster_gtk/helpers.py +++ b/hamster_gtk/helpers.py @@ -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, diff --git a/hamster_gtk/tracking/screens.py b/hamster_gtk/tracking/screens.py index 5af97788..6c3232a4 100644 --- a/hamster_gtk/tracking/screens.py +++ b/hamster_gtk/tracking/screens.py @@ -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 @@ -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