[hamster-applet] be more permissive when looking for tags and don't glue them together on return. fixes bug 628360



commit 6f4c90d14f1a322d13e8776d84d9e35c491d18eb
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Aug 30 21:54:35 2010 +0100

    be more permissive when looking for tags and don't glue them together on return. fixes bug 628360

 src/hamster/utils/stuff.py |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)
---
diff --git a/src/hamster/utils/stuff.py b/src/hamster/utils/stuff.py
index b8ab4a9..97125c4 100644
--- a/src/hamster/utils/stuff.py
+++ b/src/hamster/utils/stuff.py
@@ -294,19 +294,9 @@ class Fact(object):
             activity, self.description = activity.split(",", 1)
             self.description = self.description.strip()
 
-            # tags are marked with hash sign and parsed only at the end of description
-            # stop looking for tags if we stumble upon a non tag
-            words = self.description.split(" ")
-            parsed_tags = []
-            for word in reversed(words):
-                if word.startswith("#"):
-                    parsed_tags.append(word.strip("#,"))  #avoid commas
-                else:
-                    break
-
-            if parsed_tags:
-                self.tags = parsed_tags
-                self.description = " ".join(self.description.split(" ")[:-len(self.tags)])
+            if "#" in self.description:
+                self.description, self.tags = self.description.split("#", 1)
+                self.tags = [tag.strip(", ") for tag in self.tags.split("#") if tag.strip(", ")]
 
         if activity.find("@") > 0:
             activity, self.category = activity.split("@", 1)
@@ -321,10 +311,8 @@ class Fact(object):
         self.activity = activity.strip()
 
         tags = tags or ""
-        if tags and isinstance(tags, list):
-            tags = " ".join(tags)
-
-        tags = [tag.strip() for tag in tags.split(",") if tag.strip()]
+        if tags and isinstance(tags, basestring):
+            tags = [tag.strip() for tag in tags.split(",") if tag.strip()]
 
         # override implicit with explicit
         self.category = category.replace("#", "").replace(",", "") or self.category or None



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]