Permalink
Browse files

Make kitsune flake8 compliant.

  • Loading branch information...
1 parent b64557e commit 1cff5af95a54be73cf0abb46d4d50b0d5f4d66a3 @mythmon mythmon committed Jan 6, 2014
Showing with 1,437 additions and 1,334 deletions.
  1. +2 −1 kitsune/announcements/forms.py
  2. +4 −4 kitsune/announcements/models.py
  3. +1 −3 kitsune/announcements/tasks.py
  4. +3 −3 kitsune/announcements/tests/test_views.py
  5. +2 −1 kitsune/announcements/urls.py
  6. +2 −2 kitsune/announcements/views.py
  7. +1 −1 kitsune/customercare/admin.py
  8. +3 −2 kitsune/customercare/cron.py
  9. +2 −1 kitsune/customercare/helpers.py
  10. +2 −1 kitsune/customercare/models.py
  11. +1 −1 kitsune/customercare/tests/__init__.py
  12. +0 −1 kitsune/customercare/tests/test_cron.py
  13. +1 −1 kitsune/customercare/tests/test_templates.py
  14. +0 −1 kitsune/customercare/tests/test_views.py
  15. +2 −1 kitsune/customercare/urls.py
  16. +7 −8 kitsune/customercare/views.py
  17. +8 −8 kitsune/dashboards/cron.py
  18. +195 −179 kitsune/dashboards/readouts.py
  19. +0 −1 kitsune/dashboards/tests/__init__.py
  20. +4 −4 kitsune/dashboards/tests/test_cron.py
  21. +18 −3 kitsune/dashboards/tests/test_models.py
  22. +38 −38 kitsune/dashboards/tests/test_readouts.py
  23. +8 −6 kitsune/dashboards/tests/test_views.py
  24. +2 −1 kitsune/dashboards/urls.py
  25. +33 −32 kitsune/dashboards/utils.py
  26. +2 −3 kitsune/flagit/models.py
  27. +2 −4 kitsune/flagit/tests/__init__.py
  28. +0 −1 kitsune/flagit/tests/test_permissions.py
  29. +1 −1 kitsune/flagit/tests/test_templates.py
  30. +2 −1 kitsune/flagit/urls.py
  31. +1 −1 kitsune/forums/feeds.py
  32. +30 −22 kitsune/forums/forms.py
  33. +2 −4 kitsune/forums/models.py
  34. +10 −7 kitsune/forums/tests/test_notifications.py
  35. +1 −2 kitsune/forums/tests/test_posts.py
  36. +1 −1 kitsune/forums/tests/test_templates.py
  37. +32 −33 kitsune/forums/urls.py
  38. +2 −2 kitsune/forums/views.py
  39. +13 −15 kitsune/gallery/forms.py
  40. +2 −1 kitsune/gallery/urls.py
  41. +0 −2 kitsune/gallery/utils.py
  42. +4 −2 kitsune/groups/urls.py
  43. +5 −5 kitsune/groups/views.py
  44. +2 −1 kitsune/inproduct/urls.py
  45. +2 −1 kitsune/karma/admin.py
  46. +3 −2 kitsune/karma/api.py
  47. +0 −1 kitsune/karma/forms.py
  48. +3 −3 kitsune/karma/manager.py
  49. +6 −3 kitsune/karma/tests/test_manager.py
  50. +4 −2 kitsune/karma/urls.py
  51. +17 −14 kitsune/kbadge/management/commands/award_badges.py
  52. +1 −1 kitsune/kbadge/tests/test_awards.py
  53. +2 −1 kitsune/kbadge/urls.py
  54. +1 −1 kitsune/kbforums/feeds.py
  55. +21 −21 kitsune/kbforums/forms.py
  56. +6 −3 kitsune/kbforums/tests/test_notifications.py
  57. +0 −1 kitsune/kbforums/tests/test_views.py
  58. +2 −1 kitsune/kbforums/urls.py
  59. +6 −6 kitsune/kbforums/views.py
  60. +31 −26 kitsune/kpi/api.py
  61. +11 −12 kitsune/kpi/cron.py
  62. +13 −14 kitsune/kpi/tests/test_api.py
  63. +29 −13 kitsune/kpi/tests/test_cron.py
  64. +2 −1 kitsune/kpi/urls.py
  65. +2 −1 kitsune/landings/urls.py
  66. +0 −2 kitsune/messages/context_processors.py
  67. +1 −3 kitsune/messages/tasks.py
  68. +1 −1 kitsune/messages/tests/test_views.py
  69. +2 −1 kitsune/messages/urls.py
  70. +5 −3 kitsune/messages/views.py
  71. +2 −1 kitsune/offline/urls.py
  72. +2 −1 kitsune/postcrash/urls.py
  73. +0 −1 kitsune/products/__init__.py
  74. +4 −2 kitsune/products/tests/test_templates.py
  75. +4 −2 kitsune/products/urls.py
  76. +63 −59 kitsune/questions/config.py
  77. +16 −14 kitsune/questions/forms.py
  78. +3 −5 kitsune/questions/managers.py
  79. +29 −24 kitsune/questions/models.py
  80. +3 −2 kitsune/questions/tasks.py
  81. +1 −1 kitsune/questions/tests/test_es.py
  82. +2 −2 kitsune/questions/tests/test_forms.py
  83. +15 −8 kitsune/questions/tests/test_notifications.py
  84. +1 −2 kitsune/questions/tests/test_tasks.py
  85. +17 −18 kitsune/questions/tests/test_templates.py
  86. +11 −11 kitsune/questions/tests/test_views.py
  87. +2 −1 kitsune/questions/urls.py
  88. +23 −24 kitsune/questions/views.py
  89. +3 −2 kitsune/search/admin.py
  90. +13 −13 kitsune/search/es_utils.py
  91. +1 −1 kitsune/search/forms.py
  92. +7 −7 kitsune/search/models.py
  93. +0 −1 kitsune/search/tests/test_cmds.py
  94. +3 −4 kitsune/search/tests/test_es.py
  95. +4 −2 kitsune/search/tests/test_json.py
  96. +13 −8 kitsune/search/tests/test_search.py
  97. +2 −1 kitsune/search/urls.py
  98. +1 −1 kitsune/search/utils.py
  99. +20 −16 kitsune/search/views.py
  100. +1 −1 kitsune/sumo/anonymous.py
  101. +2 −2 kitsune/sumo/context_processors.py
  102. +1 −1 kitsune/sumo/decorators.py
  103. +9 −8 kitsune/sumo/email_utils.py
  104. +2 −2 kitsune/sumo/form_fields.py
  105. +5 −4 kitsune/sumo/googleanalytics.py
  106. +12 −10 kitsune/sumo/helpers.py
  107. +3 −3 kitsune/sumo/middleware.py
  108. +6 −5 kitsune/sumo/monkeypatch.py
  109. +6 −6 kitsune/sumo/tests/__init__.py
  110. +94 −46 kitsune/sumo/tests/test_googleanalytics.py
  111. +6 −6 kitsune/sumo/tests/test_helpers.py
  112. +4 −4 kitsune/sumo/tests/test_json_decorator.py
  113. +9 −9 kitsune/sumo/tests/test_middleware.py
  114. +2 −3 kitsune/sumo/tests/test_parser.py
  115. +1 −1 kitsune/sumo/tests/test_views.py
  116. +1 −1 kitsune/sumo/urlresolvers.py
  117. +6 −3 kitsune/sumo/urls.py
  118. +7 −8 kitsune/sumo/utils.py
  119. +2 −2 kitsune/sumo/views.py
  120. +6 −7 kitsune/tags/forms.py
  121. +2 −2 kitsune/tags/tests/test_helpers.py
  122. +1 −1 kitsune/twitter/__init__.py
  123. +0 −1 kitsune/twitter/middleware.py
  124. +1 −1 kitsune/upload/forms.py
  125. +2 −3 kitsune/upload/tests/__init__.py
  126. BIN ...ile_namelong_file_namelong_file_namelong_file_namelong_file_namelong_file_namelong_file_name.jpg}
  127. +0 −1 kitsune/upload/tests/test_models.py
  128. +1 −1 kitsune/upload/tests/test_tasks.py
  129. +3 −7 kitsune/upload/tests/test_views.py
  130. +2 −1 kitsune/upload/urls.py
  131. +4 −4 kitsune/upload/utils.py
  132. +5 −3 kitsune/urls.py
  133. +10 −10 kitsune/users/api.py
  134. +9 −9 kitsune/users/forms.py
  135. +1 −0 kitsune/users/tests/test__utils.py
  136. +0 −1 kitsune/users/tests/test_api.py
  137. +5 −6 kitsune/users/tests/test_forms.py
  138. +6 −6 kitsune/users/tests/test_helpers.py
  139. +0 −1 kitsune/users/tests/test_models.py
  140. +1 −1 kitsune/users/tests/test_views.py
  141. +10 −6 kitsune/users/urls.py
  142. +1 −0 kitsune/users/utils.py
  143. +8 −7 kitsune/users/views.py
  144. +14 −17 kitsune/wiki/config.py
  145. +6 −10 kitsune/wiki/events.py
  146. +4 −4 kitsune/wiki/facets.py
  147. +19 −21 kitsune/wiki/forms.py
  148. +1 −1 kitsune/wiki/locale_views.py
  149. +45 −45 kitsune/wiki/models.py
  150. +3 −4 kitsune/wiki/parser.py
  151. +0 −8 kitsune/wiki/showfor.py
  152. +2 −2 kitsune/wiki/tasks.py
  153. +0 −1 kitsune/wiki/tests/test_admin.py
  154. +15 −11 kitsune/wiki/tests/test_models.py
  155. +0 −1 kitsune/wiki/tests/test_notifications.py
  156. +12 −11 kitsune/wiki/tests/test_parser.py
  157. +2 −2 kitsune/wiki/tests/test_showfor.py
  158. +2 −1 kitsune/wiki/tests/test_tasks.py
  159. +108 −100 kitsune/wiki/tests/test_templates.py
  160. +26 −19 kitsune/wiki/tests/test_views.py
  161. +8 −4 kitsune/wiki/urls.py
  162. +4 −4 kitsune/wiki/utils.py
  163. +22 −21 kitsune/wiki/views.py
  164. +0 −6 scripts/pylint.sh
  165. +0 −53 scripts/pylintrc
@@ -16,7 +16,8 @@ class AnnouncementForm(forms.Form):
"""
content = forms.CharField(label=_lazy(u'Content'), max_length=10000,
widget=forms.Textarea)
- show_after = forms.DateField(label=_lazy(u'Show after'), initial=date.today,
+ show_after = forms.DateField(label=_lazy(u'Show after'),
+ initial=date.today,
input_formats=['%Y-%m-%d'])
show_until = forms.DateField(label=_lazy(u'Show until'), required=False,
input_formats=['%Y-%m-%d'])
@@ -17,24 +17,24 @@ class Announcement(ModelBase):
default=datetime.now, db_index=True,
verbose_name='Start displaying',
help_text=('When this announcement will start appearing. '
- '(US/Pacific)'))
+ '(US/Pacific)'))
show_until = models.DateTimeField(
db_index=True, null=True, blank=True,
verbose_name='Stop displaying',
help_text=('When this announcement will stop appearing. '
- 'Leave blank for indefinite. (US/Pacific)'))
+ 'Leave blank for indefinite. (US/Pacific)'))
content = models.TextField(
max_length=10000,
help_text=("Use wiki syntax or HTML. It will display similar to a "
- "document's content."))
+ "document's content."))
group = models.ForeignKey(Group, null=True, blank=True)
locale = models.ForeignKey(Locale, null=True, blank=True)
def __unicode__(self):
excerpt = self.content[:50]
if self.group:
return u'[{group}] {excerpt}'.format(group=self.group,
- excerpt=excerpt)
+ excerpt=excerpt)
return u'{excerpt}'.format(excerpt=excerpt)
def is_visible(self):
@@ -1,15 +1,13 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
-from django.core.mail import EmailMultiAlternatives
import bleach
from celery.task import task
from tower import ugettext as _
from kitsune.announcements.models import Announcement
-from kitsune.sumo.email_utils import (
- make_mail, render_email, safe_translation, send_messages)
+from kitsune.sumo.email_utils import make_mail, safe_translation, send_messages
@task
@@ -62,9 +62,9 @@ def setUp(self):
self.locale.leaders.add(self.u)
self.locale.save()
- self.announcement = announcement(save=True, creator=self.u,
- locale=self.locale, content="Look at me!",
- show_after=datetime(2012, 01, 01, 0, 0, 0))
+ self.announcement = announcement(
+ creator=self.u, locale=self.locale, content="Look at me!",
+ show_after=datetime(2012, 01, 01, 0, 0, 0), save=True)
def _delete_test(self, id, status, count):
"""Login, or other setup, then call this."""
@@ -1,7 +1,8 @@
from django.conf.urls import patterns, url
-urlpatterns = patterns('kitsune.announcements.views',
+urlpatterns = patterns(
+ 'kitsune.announcements.views',
url(r'^/create/locale$', 'create_for_locale',
name='announcements.create_for_locale'),
url(r'^/(?P<announcement_id>\d+)/delete$', 'delete',
@@ -26,10 +26,10 @@ def create_for_locale(request):
a = Announcement(creator=user, locale=locale, **form.cleaned_data)
a.save()
return HttpResponse(json.dumps({'id': a.id}),
- content_type="application/json")
+ content_type="application/json")
else:
return HttpResponse(json.dumps(form.errors), status=400,
- content_type="application/json")
+ content_type="application/json")
@require_POST
@@ -16,7 +16,7 @@ class TweetAdmin(admin.ModelAdmin):
class ReplyAdmin(admin.ModelAdmin):
date_hierarchy = 'created'
list_display = ('tweet_id', 'user', 'twitter_username', '__unicode__',
- 'created', 'locale')
+ 'created', 'locale')
list_filter = ('locale', 'twitter_username')
search_fields = ('raw_json',)
raw_id_fields = ('user',)
@@ -202,7 +202,7 @@ def get_customercare_stats():
raw = json.loads(reply.raw_json)
user = reply.twitter_username
if user not in contributor_stats:
- if 'from_user' in raw: #For tweets collected using v1 API
+ if 'from_user' in raw: # For tweets collected using v1 API
user_data = raw
else:
user_data = raw['user']
@@ -227,7 +227,8 @@ def get_customercare_stats():
limit = settings.CC_TOP_CONTRIB_LIMIT
# Sort by whatever is in settings, break ties with 'all'
contributor_stats = sorted(contributor_stats.values(),
- key=lambda c: (c[sort_key], c['all']), reverse=True)[:limit]
+ key=lambda c: (c[sort_key], c['all']),
+ reverse=True)[:limit]
try:
redis = redis_client(name='default')
@@ -32,8 +32,9 @@ def round_percent(num):
"""Return a customercare-format percentage from a number."""
return round(num, 1) if num < 10 else int(round(num, 0))
+
@register.filter
def max(num, limit):
if num > limit:
num = limit
- return num
+ return num
@@ -43,7 +43,8 @@ class Reply(ModelBase):
The Tweet table gets truncated regularly so we can't use it for metrics.
This model is to keep track of contributor counts and such.
"""
- user = models.ForeignKey(User, null=True, blank=True, related_name='tweet_replies')
+ user = models.ForeignKey(User, null=True, blank=True,
+ related_name='tweet_replies')
twitter_username = models.CharField(max_length=20)
tweet_id = models.BigIntegerField()
raw_json = models.TextField()
@@ -68,7 +68,7 @@ def reply(**kwargs):
'text': kwargs.pop('text', 'Hey #Firefox'),
'created_at': 'Thu, 23 Sep 2010 13:58:06 +0000',
'source': '&lt;a href=&quot;http://www.tweetdeck.com&quot; '
- 'rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;',
+ 'rel=&quot;nofollow&quot;&gt;TweetDeck&lt;/a&gt;',
'user': {
'screen_name': '__jimcasey__',
'profile_image_url': 'http://a1.twimg.com/profile_images/'
@@ -18,7 +18,6 @@
from kitsune.sumo.tests import TestCase
-
class TwitterCronTestCase(TestCase):
tweet_template = {
"profile_image_url": (
@@ -125,7 +125,7 @@ def test_fallback_message(self):
eq_(200, r.status_code)
doc = pq(r.content)
assert doc('#tweets-wrap .warning-box'), (
- 'Fallback message is not showing up.')
+ 'Fallback message is not showing up.')
class StatsTests(TestCase):
@@ -1,6 +1,5 @@
from datetime import datetime, timedelta
import json
-import time
from django.conf import settings
@@ -1,7 +1,8 @@
from django.conf.urls import patterns, url
-urlpatterns = patterns('kitsune.customercare.views',
+urlpatterns = patterns(
+ 'kitsune.customercare.views',
url(r'^/more_tweets$', 'more_tweets', name="customercare.more_tweets"),
url(r'^/twitter_post$', 'twitter_post', name="customercare.twitter_post"),
url(r'^/hide_tweet$', 'hide_tweet', name="customercare.hide_tweet"),
@@ -1,8 +1,7 @@
-import calendar
import json
import logging
from datetime import datetime, timedelta
-from email.utils import parsedate, formatdate
+from email.utils import parsedate
from django.conf import settings
from django.http import (HttpResponse, HttpResponseBadRequest,
@@ -46,7 +45,7 @@ def _tweet_for_template(tweet, https=False):
else:
replies = None
- if 'from_user' in data: #For tweets collected using v1 API
+ if 'from_user' in data: # For tweets collected using v1 API
user_data = data
from_user = data['from_user']
else:
@@ -242,10 +241,10 @@ def twitter_post(request):
# replying to a deleted tweet. TODO: Catch integrity error and log or
# something.
tweet = Tweet.objects.create(pk=status['id'],
- raw_json=json.dumps(raw_tweet_data),
- locale=author['lang'],
- created=created_at,
- reply_to_id=reply_to_id)
+ raw_json=json.dumps(raw_tweet_data),
+ locale=author['lang'],
+ created=created_at,
+ reply_to_id=reply_to_id)
# Record in our Reply table.
Reply.objects.create(
@@ -287,7 +286,7 @@ def hide_tweet(request):
return HttpResponseNotFound(_('Invalid ID.'))
if (tweet.reply_to is not None or
- Tweet.objects.filter(reply_to=tweet).exists()):
+ Tweet.objects.filter(reply_to=tweet).exists()):
return HttpResponseBadRequest(_('Tweets that are replies or have '
'replies must not be hidden.'))
View
@@ -63,7 +63,7 @@ def update_l10n_coverage_metrics():
# % of all articles
all_ = rows['all']
try:
- percent = 100.0 * float(all_['numerator']) / all_['denominator']
+ percent = 100 * float(all_['numerator']) / all_['denominator']
except ZeroDivisionError:
percent = 0.0
@@ -253,10 +253,10 @@ def _bayes_avg(C, m, R, v):
for entry in sorted_final:
doc = Document.objects.get(pk=entry[0])
redis.rpush(REDIS_KEY, (u'%s::%s::%s::%s::%s::%s::%s' %
- (entry[0], # Document ID
- entry[1], # Total Votes
- entry[2], # Current Percentage
- entry[3], # Difference in Percentage
- 1 - (entry[1] / max_total), # Graph Color
- doc.slug, # Document slug
- doc.title))) # Document title
+ (entry[0], # Document ID
+ entry[1], # Total Votes
+ entry[2], # Current Percentage
+ entry[3], # Difference in Percentage
+ 1 - (entry[1] / max_total), # Graph Color
+ doc.slug, # Document slug
+ doc.title))) # Document title
Oops, something went wrong.

0 comments on commit 1cff5af

Please sign in to comment.