Commits

Bruno Renié committed 3f455ae

Fixed a bunch of flake8 errors

Comments (0)

Files changed (4)

dotim/activity/templatetags/twitterfy.py

 @register.filter(name='twitterfy')
 def twitterfy(tweet):
     # find hashtags
-    pattern = re.compile(r"(?P<start>.?) #(?P<hashtag>[A-Za-z0-9_]+)(?P<end>.?)")
+    pattern = re.compile(
+        r"(?P<start>.?) #(?P<hashtag>[A-Za-z0-9_]+)(?P<end>.?)"
+    )
     pattern2 = re.compile(r"^#(?P<hashtag>[A-Za-z0-9_]+)(?P<end>.?)")
 
     # replace with link to search
-    link = r'\g<start> #<a href="http://search.twitter.com/search?q=\g<hashtag>"  title="#\g<hashtag> on Twitter">\g<hashtag></a>\g<end>'
-    link2 = r'#<a href="http://search.twitter.com/search?q=\g<hashtag>"  title="#\g<hashtag> on Twitter">\g<hashtag></a>\g<end>'
+    link = (r'\g<start> #<a href="http://search.twitter.com/search?'
+            r'q=\g<hashtag>"  title="#\g<hashtag> on Twitter">\g'
+            '<hashtag></a>\g<end>')
+    link2 = (r'<a href="http://search.twitter.com/search?q=\g<hashtag>" '
+             r'title="#\g<hashtag> on Twitter">#\g<hashtag></a>\g<end>')
     text = pattern.sub(link, tweet)
     text = pattern2.sub(link2, text)
 
     pattern = re.compile(r"(?P<start>.?)@(?P<user>[A-Za-z0-9_]+)(?P<end>.?)")
 
     # replace with link to profile
-    link = r'\g<start>@<a href="http://twitter.com/\g<user>"  title="@\g<user> on Twitter">\g<user></a>\g<end>'
+    link = (r'\g<start><a href="http://twitter.com/\g<user>" '
+            r'title="@\g<user> on Twitter">@\g<user></a>\g<end>')
     text = pattern.sub(link, text)
 
     return mark_safe(text)

dotim/activity/tests/__init__.py

         conf.filters = 'aspirator'
         conf.save()
         self._test_feed(2)
-        self.assertEquals(Event.objects.count(), 27) # 35 if not filtered
+        self.assertEquals(Event.objects.count(), 27)  # 35 if not filtered
 
     def test_error(self):
         conf = EventConfig.objects.get(pk=2)

dotim/blog/models.py

     if instance.object is None:
         return
     ctype = ContentType.objects.get(app_label='blog', model='entry')
-    tags = tagging.models.TaggedItem.objects.filter(content_type=ctype,
-        object_id=instance.object.id).select_related().values_list('tag__name', flat=True)
+    tags = tagging.models.TaggedItem.objects.filter(
+        content_type=ctype, object_id=instance.object.pk,
+    ).select_related().values_list('tag__name', flat=True)
     instance.object._tags = ','.join(tags)
     instance.object.save()
 models.signals.post_save.connect(update_tags, sender=TaggedItem)

dotim/blog/templatetags/include_tags.py

     try:
         tag_name, template_name = token.split_contents()
     except ValueError:
-        raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0]
+        raise template.TemplateSyntaxError(
+            "%r tag requires a single argument" % token.contents.split()[0]
+        )
 
     return IncludeNode(template_name[1:-1])