Commits

Gustavo Picon committed c1d4984

pep8

Comments (0)

Files changed (2)

         return cls.JOINER.join(results)
 
 
-
 class DeliciousTokenizer(Tokenizer):
     """ Tokenizer for Delicious-like tags.
 
             char = lstr[0]
             if char == '"':
                 quoted = not quoted
-            elif char == ' ' and \
-                    (not quoted or \
-                    (quoted and prev == '"' and '"' not in lstr)):
+            elif (char == ' '
+                  and (not quoted
+                       or (quoted and prev == '"' and '"' not in lstr))):
                 if tok:
                     quoted = False
                     cls._process_tag(tags, keys, tok)

test/test_tagtools.py

 
 """Test tagtools.py"""
 
-from tagtools import FlickrTokenizer, DeliciousTokenizer, CommaTokenizer, \
-                     TagWithSeparatorException
+from tagtools import (
+    FlickrTokenizer, DeliciousTokenizer,
+    CommaTokenizer, TagWithSeparatorException)
 import pytest
 
 
      [('tag1    tag', 'TaG1    tAg'), ('number', 'nUmber'),
       ('2', '2'), ('tag3', 'taG3')]),
     ('   Ta"G"1    "tAg     numbEr   2"    taG3    ',
-     [('tag1', 'TaG1'), ('tag     number   2',
-       'tAg     numbEr   2'), ('tag3', 'taG3')]),
+     [('tag1', 'TaG1'),
+      ('tag     number   2', 'tAg     numbEr   2'),
+      ('tag3', 'taG3')]),
     ('   t"A"G"1    "tAg     nUMber   2"    tAG3    ',
      [('tag1    tag', 'tAG1    tAg'), ('number', 'nUMber'),
      ('2', '2'), ('tag3', 'tAG3')]),
     ('TaG taG GAT tag gat', [('tag', 'TaG'), ('gat', 'GAT')]),
     ('"TaG" taG GAT "tag" g"a"t', [('tag', 'TaG'), ('gat', 'GAT')]),
     # machine tags tests
-    (
-     'tag1 tag2:foo tag3:bar=baz tag4:aa="a b c d" "  tag5:bb="e f g h',
-      [('tag1', 'tag1'), ('tag2:foo', 'tag2:foo'),
-       ('tag3:bar=baz', 'tag3:bar=baz', 'tag3', 'bar', 'baz'),
-       ('tag4:aa=a b c d', 'tag4:aa=a b c d', 'tag4', 'aa', 'a b c d'),
-       ('tag5:bb=e', 'tag5:bb=e', 'tag5', 'bb', 'e'),
-       ('f', 'f'), ('g', 'g'), ('h', 'h')])])
+    ('tag1 tag2:foo tag3:bar=baz tag4:aa="a b c d" "  tag5:bb="e f g h',
+     [('tag1', 'tag1'), ('tag2:foo', 'tag2:foo'),
+      ('tag3:bar=baz', 'tag3:bar=baz', 'tag3', 'bar', 'baz'),
+      ('tag4:aa=a b c d', 'tag4:aa=a b c d', 'tag4', 'aa', 'a b c d'),
+      ('tag5:bb=e', 'tag5:bb=e', 'tag5', 'bb', 'e'),
+      ('f', 'f'), ('g', 'g'), ('h', 'h')])])
 def test_flickr_str2tags(tagstr, expected):
     str2tags_helper(FlickrTokenizer, tagstr, expected)
 
 
 
 @pytest.mark.parametrize(("tagstr", "expected"), [
-        (None, []),
-        ('', []),
-        (',', []),
-        (',,,,,,', []),
-        ('T1', [('t1', 'T1')]),
-        ('  T   1   ', [('t   1', 'T   1')]),
-        (',,,,,,,T1', [('t1', 'T1')]),
-        (',,,,,,, T  1 ', [('t  1', 'T  1')]),
-        ('T1,,,,,,,,,', [('t1', 'T1')]),
-        ('T1,T2,T3', [('t1', 'T1'), ('t2', 'T2'), ('t3', 'T3')]),
-        (',,,T1,,,,T2,,,,T3,,,',
-         [('t1', 'T1'), ('t2', 'T2'), ('t3', 'T3')]),
-        (',,,T   1,,,,T 2,,,,T    3,,,',
-         [('t   1', 'T   1'), ('t 2', 'T 2'), ('t    3', 'T    3')]),
-        ('TaG,taG,GAT,tag,gat', [('tag', 'TaG'), ('gat', 'GAT')])])
+    (None, []),
+    ('', []),
+    (',', []),
+    (',,,,,,', []),
+    ('T1', [('t1', 'T1')]),
+    ('  T   1   ', [('t   1', 'T   1')]),
+    (',,,,,,,T1', [('t1', 'T1')]),
+    (',,,,,,, T  1 ', [('t  1', 'T  1')]),
+    ('T1,,,,,,,,,', [('t1', 'T1')]),
+    ('T1,T2,T3', [('t1', 'T1'), ('t2', 'T2'), ('t3', 'T3')]),
+    (',,,T1,,,,T2,,,,T3,,,',
+     [('t1', 'T1'), ('t2', 'T2'), ('t3', 'T3')]),
+    (',,,T   1,,,,T 2,,,,T    3,,,',
+     [('t   1', 'T   1'), ('t 2', 'T 2'), ('t    3', 'T    3')]),
+    ('TaG,taG,GAT,tag,gat', [('tag', 'TaG'), ('gat', 'GAT')])])
 def test_comma_str2tags(tagstr, expected):
     str2tags_helper(CommaTokenizer, tagstr, expected)
 
     (['t1', 't2', 't3'], 't1 t2 t3'),
     (['t1   t2', 't3'], '"t1   t2" t3'),
     (['tag1    tag', 'number', '2', 'tag3'],
-      '"tag1    tag" number 2 tag3'),
+     '"tag1    tag" number 2 tag3'),
     (['tag1', 'tag     number   2', 'tag3'],
-      'tag1 "tag     number   2" tag3'),
+     'tag1 "tag     number   2" tag3'),
     (['tag1    tag', 'number', '2', 'tag3'],
-      '"tag1    tag" number 2 tag3'),
+     '"tag1    tag" number 2 tag3'),
     (['tag1    tag     number   2', 'tag3'],
-      '"tag1    tag     number   2" tag3'),
+     '"tag1    tag     number   2" tag3'),
     (['tag1', 'tag', 'number   2', 'tag3'],
-      'tag1 tag "number   2" tag3'),
+     'tag1 tag "number   2" tag3'),
     (['tag1', 'tag', 'number', '2    tag3'],
-      'tag1 tag number "2    tag3"'),
+     'tag1 tag number "2    tag3"'),
     (['tag1', 'tag', 'number', '2', 'tag3'],
-      'tag1 tag number 2 tag3')])
+     'tag1 tag number 2 tag3')])
 def test_flickr_tags2str(tags, expected):
     assert FlickrTokenizer.tags2str(tags) == expected
 
 
 def test_delicious_tag2str_separator_exception():
     pytest.raises(TagWithSeparatorException,
-            DeliciousTokenizer.tags2str, ['t 1'])
+                  DeliciousTokenizer.tags2str, ['t 1'])
 
 
 @pytest.mark.parametrize(("tags", "expected"), [