Skip to content

Commit 17d4a84

Browse files
committed
pep8 fixes
1 parent 5c8d6b3 commit 17d4a84

File tree

8 files changed

+42
-32
lines changed

8 files changed

+42
-32
lines changed

codespeed/commits/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, unicode_literals
33

4+
45
class CommitLogError(Exception):
56
"""An error when trying to display commit log messages"""

codespeed/commits/git.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def updaterepo(project, update=True):
1616
return
1717

1818
p = Popen(['git', 'pull'], stdout=PIPE, stderr=PIPE,
19-
cwd=project.working_copy)
19+
cwd=project.working_copy)
2020

2121
stdout, stderr = p.communicate()
2222
if p.returncode != 0:
@@ -27,7 +27,7 @@ def updaterepo(project, update=True):
2727
else:
2828
cmd = ['git', 'clone', project.repo_path, project.repo_name]
2929
p = Popen(cmd, stdout=PIPE, stderr=PIPE,
30-
cwd=settings.REPOSITORY_BASE_PATH)
30+
cwd=settings.REPOSITORY_BASE_PATH)
3131
logger.debug('Cloning Git repo {0} for project {1}'.format(
3232
project.repo_path, project))
3333
stdout, stderr = p.communicate()
@@ -43,9 +43,9 @@ def getlogs(endrev, startrev):
4343
updaterepo(endrev.branch.project, update=False)
4444

4545
cmd = ["git", "log",
46-
# NULL separated values delimited by 0x1e record separators
47-
# See PRETTY FORMATS in git-log(1):
48-
'--format=format:%h%x00%H%x00%at%x00%an%x00%ae%x00%s%x00%b%x1e']
46+
# NULL separated values delimited by 0x1e record separators
47+
# See PRETTY FORMATS in git-log(1):
48+
'--format=format:%h%x00%H%x00%at%x00%an%x00%ae%x00%s%x00%b%x1e']
4949

5050
if endrev.commitid != startrev.commitid:
5151
cmd.append("%s...%s" % (startrev.commitid, endrev.commitid))
@@ -67,7 +67,7 @@ def getlogs(endrev, startrev):
6767
subject, body) = log.split("\x00", 7)
6868

6969
date = datetime.datetime.fromtimestamp(
70-
int(date_t)).strftime("%Y-%m-%d %H:%M:%S")
70+
int(date_t)).strftime("%Y-%m-%d %H:%M:%S")
7171

7272
logs.append({'date': date, 'message': subject, 'commitid': commit_id,
7373
'author': author_name, 'author_email': author_email,

codespeed/commits/github.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ def retrieve_revision(commit_id, username, project, revision=None):
4848
raise e
4949

5050
if commit_json["message"] in ("Not Found", "Server Error",):
51-
# We'll still cache these for a brief period of time to avoid making too many requests:
51+
# We'll still cache these for a brief period of time to avoid
52+
# making too many requests:
5253
cache.set(commit_url, commit_json, 300)
5354
else:
5455
# We'll cache successes for a very long period of time since
5556
# SCM diffs shouldn't change:
5657
cache.set(commit_url, commit_json, 86400 * 30)
5758

5859
if commit_json["message"] in ("Not Found", "Server Error",):
59-
raise CommitLogError("Unable to load %s: %s" % (commit_url, commit_json["message"]))
60+
raise CommitLogError(
61+
"Unable to load %s: %s" % (commit_url, commit_json["message"]))
6062

6163
date = isodate.parse_datetime(commit_json['committer']['date'])
6264

@@ -66,7 +68,8 @@ def retrieve_revision(commit_id, username, project, revision=None):
6668

6769
# We need to convert the timezone-aware date to a naive (i.e.
6870
# timezone-less) date in UTC to avoid killing MySQL:
69-
revision.date = date.astimezone(isodate.tzinfo.Utc()).replace(tzinfo=None)
71+
revision.date = date.astimezone(
72+
isodate.tzinfo.Utc()).replace(tzinfo=None)
7073
revision.author = commit_json['author']['name']
7174
revision.message = commit_json['message']
7275
revision.full_clean()
@@ -85,7 +88,7 @@ def retrieve_revision(commit_id, username, project, revision=None):
8588
def getlogs(endrev, startrev):
8689
if endrev != startrev:
8790
revisions = endrev.branch.revisions.filter(
88-
date__lte=endrev.date, date__gte=startrev.date)
91+
date__lte=endrev.date, date__gte=startrev.date)
8992
else:
9093
revisions = [i for i in (startrev, endrev) if i.commitid]
9194

@@ -105,23 +108,29 @@ def getlogs(endrev, startrev):
105108
last_rev_data = None
106109
revision_count = 0
107110
ancestor_found = False
108-
#TODO: get all revisions between endrev and startrev,
111+
# TODO: get all revisions between endrev and startrev,
109112
# not only those present in the Codespeed DB
110113

111114
for revision in revisions:
112-
last_rev_data = retrieve_revision(revision.commitid, username, project, revision)
115+
last_rev_data = retrieve_revision(
116+
revision.commitid, username, project, revision)
113117
logs.append(last_rev_data)
114118
revision_count += 1
115-
ancestor_found = (startrev.commitid in [rev['sha'] for rev in last_rev_data['parents']])
119+
ancestor_found = (
120+
startrev.commitid in [
121+
rev['sha'] for rev in last_rev_data['parents']])
116122

117123
# Simple approach to find the startrev, stop after found or after
118124
# #GITHUB_REVISION_LIMIT revisions are fetched
119125
while (revision_count < GITHUB_REVISION_LIMIT
120126
and not ancestor_found
121127
and len(last_rev_data['parents']) > 0):
122-
last_rev_data = retrieve_revision(last_rev_data['parents'][0]['sha'], username, project)
128+
last_rev_data = retrieve_revision(
129+
last_rev_data['parents'][0]['sha'], username, project)
123130
logs.append(last_rev_data)
124131
revision_count += 1
125-
ancestor_found = (startrev.commitid in [rev['sha'] for rev in last_rev_data['parents']])
132+
ancestor_found = (
133+
startrev.commitid in [
134+
rev['sha'] for rev in last_rev_data['parents']])
126135

127136
return sorted(logs, key=lambda i: i['date'], reverse=True)

codespeed/models.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def save(self, *args, **kwargs):
329329

330330
super(Report, self).save(*args, **kwargs)
331331

332-
def updown(self,val):
333-
#Substitute plus/minus with up/down
332+
def updown(self, val):
333+
"""Substitutes plus/minus with up/down"""
334334
direction = val >= 0 and "up" or "down"
335335
aval = abs(val)
336336
if aval == float("inf"):
@@ -343,8 +343,8 @@ def is_big_change(self, val, color, current_val, current_color):
343343
return True
344344
elif color == "red" and abs(val) > abs(current_val):
345345
return True
346-
elif (color == "green" and current_color != "red"
347-
and abs(val) > abs(current_val)):
346+
elif (color == "green" and current_color != "red" and
347+
abs(val) > abs(current_val)):
348348
return True
349349
else:
350350
return False
@@ -402,7 +402,8 @@ def get_changes_table(self, trend_depth=10, force_save=False):
402402
)
403403

404404
tablelist = []
405-
for units_title in Benchmark.objects.all().values_list('units_title', flat=True).distinct():
405+
for units_title in Benchmark.objects.all().values_list(
406+
'units_title', flat=True).distinct():
406407
currentlist = []
407408
units = ""
408409
hasmin = False
@@ -550,4 +551,3 @@ def _get_tablecache(self):
550551
if self._tablecache == '':
551552
return {}
552553
return json.loads(self._tablecache)
553-

codespeed/templatetags/percentages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
register = template.Library()
66

7+
78
@register.filter
89
def percentage(value):
910
if value == "-":
@@ -13,9 +14,10 @@ def percentage(value):
1314
else:
1415
return "%.2f" % value
1516

17+
1618
@register.filter
1719
def fix_infinity(value):
18-
'''Python’s ∞ prints "inf", but JavaScript wants "Infinity"'''
20+
"""Python’s ∞ prints 'inf', but JavaScript wants 'Infinity'"""
1921
if value == float("inf"):
2022
return "Infinity"
2123
elif value == float("-inf"):

codespeed/urls.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# -*- coding: utf-8 -*-
2-
from django.conf.urls import patterns, include, url
3-
from django.core.urlresolvers import reverse
2+
from django.conf.urls import patterns, url
43
from django.views.generic import TemplateView
54

65
from codespeed.feeds import LatestEntries, LatestSignificantEntries
76

87

98
urlpatterns = patterns('',
10-
(r'^$', TemplateView.as_view(template_name='home.html')),
11-
(r'^about/$', TemplateView.as_view(template_name='about.html')),
9+
url(r'^$', TemplateView.as_view(template_name='home.html')),
10+
url(r'^about/$', TemplateView.as_view(template_name='about.html')),
1211
# RSS for reports
1312
url(r'^feeds/latest/$', LatestEntries(), name='latest_feeds'),
14-
url(r'^feeds/latest_significant/$', LatestSignificantEntries(), name='latest_significant_feeds'),
13+
url(r'^feeds/latest_significant/$', LatestSignificantEntries(),
14+
name='latest_significant_feeds'),
1515
)
1616

1717
urlpatterns += patterns('codespeed.views',
@@ -27,6 +27,6 @@
2727

2828
urlpatterns += patterns('codespeed.views',
2929
# URLs for adding results
30-
(r'^result/add/json/$', 'add_json_results'),
31-
(r'^result/add/$', 'add_result'),
30+
url(r'^result/add/json/$', 'add_json_results'),
31+
url(r'^result/add/$', 'add_result'),
3232
)

codespeed/views_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
from django.conf import settings
55

6-
from codespeed.models import (Executable, Revision, Project, Branch, Benchmark,
7-
Result, Report)
6+
from codespeed.models import Executable, Revision, Project, Branch
87

98

109
def get_default_environment(enviros, data, multi=False):

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Django>=1.6,<1.9
22
isodate>=0.4.7,<0.6
3-

0 commit comments

Comments
 (0)