Skip to content

Commit 931c26e

Browse files
committed
Remove vim config from create_apikey, lots of pep8 fixes
1 parent 2fc727c commit 931c26e

18 files changed

Lines changed: 178 additions & 135 deletions

codespeed/admin.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,52 @@ class ProjectAdmin(admin.ModelAdmin):
1111

1212
admin.site.register(Project, ProjectAdmin)
1313

14+
1415
class BranchAdmin(admin.ModelAdmin):
1516
list_display = ('name', 'project')
1617

1718
admin.site.register(Branch, BranchAdmin)
1819

20+
1921
class RevisionAdmin(admin.ModelAdmin):
2022
list_display = ('commitid', 'branch', 'tag', 'date')
21-
list_filter = ('branch', 'tag', 'date')
23+
list_filter = ('branch', 'tag', 'date')
2224
search_fields = ('commitid', 'tag')
2325

2426
admin.site.register(Revision, RevisionAdmin)
2527

28+
2629
class ExecutableAdmin(admin.ModelAdmin):
2730
list_display = ('name', 'description', 'id', 'project')
2831
search_fields = ('name', 'description', 'project')
2932

3033
admin.site.register(Executable, ExecutableAdmin)
3134

35+
3236
class BenchmarkAdmin(admin.ModelAdmin):
33-
list_display = ('name', 'benchmark_type', 'description', 'units_title', 'units', 'lessisbetter', 'default_on_comparison')
37+
list_display = ('name', 'benchmark_type', 'description', 'units_title',
38+
'units', 'lessisbetter', 'default_on_comparison')
3439
ordering = ['name']
3540
search_fields = ('name', 'description')
3641

3742
admin.site.register(Benchmark, BenchmarkAdmin)
3843

44+
3945
class EnvironmentAdmin(admin.ModelAdmin):
4046
list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
4147
search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')
4248

4349
admin.site.register(Environment, EnvironmentAdmin)
4450

51+
4552
class ResultAdmin(admin.ModelAdmin):
46-
list_display = ('revision', 'benchmark', 'executable', 'environment', 'value', 'date', 'environment')
47-
list_filter = ('date', 'environment', 'executable', 'benchmark')
53+
list_display = ('revision', 'benchmark', 'executable', 'environment',
54+
'value', 'date', 'environment')
55+
list_filter = ('date', 'environment', 'executable', 'benchmark')
4856

4957
admin.site.register(Result, ResultAdmin)
5058

59+
5160
class ReportAdmin(admin.ModelAdmin):
5261
list_display = ('revision', 'summary', 'colorcode')
5362
ordering = ['-revision']

codespeed/api.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ class Meta:
6464
#excludes = ['email', 'password', 'is_superuser']
6565
# Add it here.
6666
#authorization = DjangoAuthorization()
67-
authorization= Authorization()
68-
#authentication = ApiKeyAuthentication()
67+
authorization = Authorization()
68+
#authentication = ApiKeyAuthentication()
6969

7070

7171
class ProjectResource(ModelResource):
7272
"""Resource for Project()"""
7373

7474
class Meta:
7575
queryset = Project.objects.all()
76-
authorization= Authorization()
76+
authorization = Authorization()
7777

7878

7979
class BranchResource(ModelResource):
@@ -83,7 +83,7 @@ class BranchResource(ModelResource):
8383

8484
class Meta:
8585
queryset = Branch.objects.all()
86-
authorization= Authorization()
86+
authorization = Authorization()
8787

8888

8989
class RevisionResource(ModelResource):
@@ -94,7 +94,7 @@ class RevisionResource(ModelResource):
9494

9595
class Meta:
9696
queryset = Revision.objects.all()
97-
authorization= Authorization()
97+
authorization = Authorization()
9898

9999

100100
class ExecutableResource(ModelResource):
@@ -104,15 +104,15 @@ class ExecutableResource(ModelResource):
104104

105105
class Meta:
106106
queryset = Executable.objects.all()
107-
authorization= Authorization()
107+
authorization = Authorization()
108108

109109

110110
class BenchmarkResource(ModelResource):
111111
"""Resource for Benchmark()"""
112112

113113
class Meta:
114114
queryset = Benchmark.objects.all()
115-
authorization= Authorization()
115+
authorization = Authorization()
116116

117117

118118
class EnvironmentResource(ModelResource):
@@ -121,15 +121,15 @@ class EnvironmentResource(ModelResource):
121121
class Meta:
122122
queryset = Environment.objects.all()
123123
resource_name = 'environment'
124-
authorization= Authorization()
124+
authorization = Authorization()
125125

126126

127127
class ResultResource(ModelResource):
128128
"""Resource for Result()"""
129129

130130
class Meta:
131131
queryset = Result.objects.all()
132-
authorization= Authorization()
132+
authorization = Authorization()
133133

134134

135135
class ReportResource(ModelResource):
@@ -142,7 +142,7 @@ class ReportResource(ModelResource):
142142
class Meta:
143143
queryset = Report.objects.all()
144144
allowed_methods = ['get']
145-
authorization= Authorization()
145+
authorization = Authorization()
146146

147147

148148
class ResultBundle(Bundle):
@@ -183,13 +183,13 @@ def __init__(self, obj=None, **kwargs):
183183
self.obj = obj
184184
self._populate_by_obj()
185185
elif obj is None:
186-
self.obj = Result()
186+
self.obj = Result()
187187
else:
188188
raise ValueError("obj has to be an instance of models.Result")
189189

190190
if self.data:
191191
self._check_data()
192-
self.__data_validated = False #not used for now
192+
self.__data_validated = False # not used for now
193193
super(ResultBundle, self).__init__(data=self.data, obj=self.obj)
194194

195195
def _populate_obj_by_data(self):
@@ -213,7 +213,7 @@ def populate(key):
213213
}.get(key, (None, None))()
214214

215215
try:
216-
self.obj.value = float(self.data['result_value'])
216+
self.obj.value = float(self.data['result_value'])
217217
except ValueError, error:
218218
logging.error(
219219
"Result value: {0} cannot be converted to float. {1}".format(
@@ -367,7 +367,7 @@ class ResultBundleResource(Resource):
367367

368368
class Meta:
369369
resource_name = 'benchmark-result'
370-
authorization= Authorization()
370+
authorization = Authorization()
371371
allowed_methods = ['get', 'post', 'put', 'delete']
372372

373373
def get_resource_uri(self, bundle_or_obj):
@@ -417,7 +417,6 @@ def obj_create(self, bundle, request=None, **kwargs):
417417
def obj_update(self, bundle, request=None, **kwargs):
418418
return self.obj_create(bundle, request, **kwargs)
419419

420-
421420
def post_list(self, request, **kwargs):
422421
"""
423422
Creates a new resource/object with the provided data.
@@ -458,4 +457,3 @@ def obj_delete(self, request=None, **kwargs):
458457

459458
def rollback(self, bundles):
460459
pass
461-

codespeed/git.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def updaterepo(project, update=True):
3737
else:
3838
return [{'error': False}]
3939

40+
4041
def getlogs(endrev, startrev):
4142
updaterepo(endrev.branch.project, update=False)
4243

@@ -48,7 +49,7 @@ def getlogs(endrev, startrev):
4849
if endrev.commitid != startrev.commitid:
4950
cmd.append("%s...%s" % (startrev.commitid, endrev.commitid))
5051
else:
51-
cmd.append("-1") # Only return one commit
52+
cmd.append("-1") # Only return one commit
5253
cmd.append(endrev.commitid)
5354

5455
working_copy = endrev.branch.project.working_copy

codespeed/github.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
# revisions.
2727
GITHUB_REVISION_LIMIT = 10
2828

29+
2930
def updaterepo(project, update=True):
3031
return
3132

3233

33-
def retrieve_revision(commit_id, username, project, revision = None):
34+
def retrieve_revision(commit_id, username, project, revision=None):
3435
commit_url = 'http://github.com/api/v2/json/commits/show/%s/%s/%s' % (
3536
username, project, commit_id)
3637

@@ -73,13 +74,14 @@ def retrieve_revision(commit_id, username, project, revision = None):
7374

7475
return {'date': date,
7576
'message': commit['message'],
76-
'body': "", # TODO: pretty-print diffs
77+
'body': "", # TODO: pretty-print diffs
7778
'author': commit['author']['name'],
7879
'author_email': commit['author']['email'],
7980
'commitid': commit['id'],
8081
'short_commit_id': commit['id'][0:7],
8182
'parents': commit['parents']}
8283

84+
8385
def getlogs(endrev, startrev):
8486
if endrev != startrev:
8587
revisions = endrev.branch.revisions.filter(
@@ -108,15 +110,15 @@ def getlogs(endrev, startrev):
108110
logs.append(last_rev_data)
109111
revision_count += 1
110112
ancestor_found = (startrev.commitid in [rev['id'] for rev in last_rev_data['parents']])
111-
113+
112114
# Simple approach to find the startrev, stop after found or after
113115
# #GITHUB_REVISION_LIMIT revisions are fetched
114-
while (revision_count < GITHUB_REVISION_LIMIT
116+
while (revision_count < GITHUB_REVISION_LIMIT
115117
and not ancestor_found
116118
and len(last_rev_data['parents']) > 0):
117119
last_rev_data = retrieve_revision(last_rev_data['parents'][0]['id'], username, project)
118120
logs.append(last_rev_data)
119121
revision_count += 1
120122
ancestor_found = (startrev.commitid in [rev['id'] for rev in last_rev_data['parents']])
121-
123+
122124
return sorted(logs, key=lambda i: i['date'], reverse=True)

codespeed/mercurial.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import os, datetime
1+
import os
2+
import datetime
23
from subprocess import Popen, PIPE
34
import logging
45

@@ -39,6 +40,7 @@ def updaterepo(project, update=True):
3940
else:
4041
return [{'error': False}]
4142

43+
4244
def getlogs(endrev, startrev):
4345
updaterepo(endrev.branch.project, update=False)
4446

@@ -54,7 +56,7 @@ def getlogs(endrev, startrev):
5456
if p.returncode != 0:
5557
raise RuntimeError(str(stderr))
5658
else:
57-
stdout = stdout.rstrip('\n')#Remove last newline
59+
stdout = stdout.rstrip('\n') # Remove last newline
5860
logs = []
5961
for log in stdout.split("=newlog=\n"):
6062
elements = []
@@ -78,9 +80,9 @@ def getlogs(endrev, startrev):
7880

7981
# Add changeset info
8082
logs.append({
81-
'date': date, 'author': author_name, 'author_email': author_email,
82-
'message': message,'short_commit_id': short_commit_id,
83-
'commitid': commit_id})
83+
'date': date, 'author': author_name,
84+
'author_email': author_email, 'message': message,
85+
'short_commit_id': short_commit_id, 'commitid': commit_id})
8486
# Remove last log here because mercurial saves the short hast as commitid now
8587
if len(logs) > 1 and logs[-1].get('short_commit_id') == startrev.commitid:
8688
logs.pop()

0 commit comments

Comments
 (0)