No need to strip the tag 4 times
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Fri, 16 Nov 2012 12:18:37 +0000 (13:18 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Fri, 16 Nov 2012 12:18:37 +0000 (13:18 +0100)
spaetz' rule: Don't do sth 4 times when once suffices.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
mediagoblin/tools/text.py

index 24a4d28217d08e51923524b98fe138bf4889f1f1..96df49d27a929d894d074c06459c853df0354244 100644 (file)
@@ -68,12 +68,11 @@ def convert_to_tag_list_of_dicts(tag_string):
 
         # Split the tag string into a list of tags
         for tag in stripped_tag_string.split(','):
-
+            tag = tag.strip()
             # Ignore empty or duplicate tags
-            if tag.strip() and tag.strip() not in [t['name'] for t in taglist]:
-
-                taglist.append({'name': tag.strip(),
-                                'slug': url.slugify(tag.strip())})
+            if tag and tag not in [t['name'] for t in taglist]:
+                taglist.append({'name': tag,
+                                'slug': url.slugify(tag)})
     return taglist