Permalink
Browse files

fix other pep8 nuissances introduced in the latest version + ignore E123

  • Loading branch information...
1 parent cb925c2 commit 258945c14d07c865ac182d3848e4f452406dc01d @mapleoin committed Jul 20, 2012
Showing with 44 additions and 31 deletions.
  1. +3 −1 .travis.yml
  2. +3 −2 popcorn/helpers.py
  3. +4 −4 popcorn/pagination.py
  4. +4 −5 popcorn/test/test_models.py
  5. +16 −11 popcorn/test/test_views.py
  6. +14 −8 popcorn/views.py
View
@@ -12,5 +12,7 @@ before_script:
- psql -c "GRANT ALL PRIVILEGES ON DATABASE popcorn TO popcorn;" -U postgres
script:
- - pep8 popcorn
+ # E123 closing bracket does not match indentation of opening bracket's line
+ # see https://github.com/jcrocholl/pep8/issues/103
+ - pep8 --ignore E123 popcorn
- python setup.py test
View
@@ -29,8 +29,9 @@
def request_wants_json():
best = request.accept_mimetypes.best_match(['application/json',
'text/html'])
- return best == 'application/json' and (request.accept_mimetypes[best] >
- request.accept_mimetypes['text/html'])
+ return (best == 'application/json'
+ and (request.accept_mimetypes[best] >
+ request.accept_mimetypes['text/html']))
def render(template=None):
View
@@ -61,10 +61,10 @@ def iter_pages(self, left_edge=2, left_current=2,
""" Generates page numbers for navigation """
last = 0
for num in xrange(1, self.pages + 1):
- if (num <= left_edge or
- (num > self.page - left_current - 1 and
- num < self.page + right_current) or
- num > self.pages - right_edge):
+ if (num <= left_edge
+ or (num > self.page - left_current - 1
+ and num < self.page + right_current)
+ or (num > self.pages - right_edge)):
if last + 1 != num:
yield None
yield num
@@ -115,11 +115,10 @@ def test_submission_package_creation(self):
def test_system_last_submission(self):
sub1 = Submission('hw_uuid1', 'P1', date.today())
- sub2 = Submission('hw_uuid2', 'P1', date.today() -
- timedelta(days=31 * 2))
- sub3 = Submission('hw_uuid1', 'P1', date.today() -
- timedelta(days=31 * 3))
-
+ sub2 = Submission('hw_uuid2', 'P1',
+ date.today() - timedelta(days=31 * 2))
+ sub3 = Submission('hw_uuid1', 'P1',
+ date.today() - timedelta(days=31 * 3))
s1 = System.query.first()
self.assertIsNone(s1.last_submission)
View
@@ -75,7 +75,7 @@ def submit(self, compress, header):
f_in = open(submission_file, 'rb')
if compress:
f = cStringIO.StringIO()
- g = gzip.GzipFile(mode='wb', fileobj=f)
+ g = gzip.GzipFile(mode='wb', fileobj=f)
g.writelines(f_in)
g.close()
f_in.close()
@@ -84,7 +84,7 @@ def submit(self, compress, header):
f = f_in
if header:
return self.app.post('/', data=dict(popcorn=(f, 'popcorn.txt.gz')),
- headers={'Content-Encoding': 'gzip', })
+ headers={'Content-Encoding': 'gzip', })
else:
return self.app.post('/', data=dict(popcorn=(f, 'popcorn.txt')))
@@ -103,7 +103,8 @@ def test_submission_plaintext_without_header(self):
def test_index_json(self):
self.submit(compress=False, header=False)
with app.test_request_context(
- path='/', method='GET', headers=[('Accept', 'application/json')]):
+ path='/', method='GET',
+ headers=[('Accept', 'application/json')]):
response = app.dispatch_request()
self.assertEqual(json.loads(response.data), {
"distro_packages": "[[\"openSUSE\", 1285]]",
@@ -128,14 +129,14 @@ def test_index_json(self):
def test_vendor_json(self):
self.submit(compress=False, header=False)
with app.test_request_context(
- path='/vendor/openSUSE', method='GET',
- headers=[('Accept', 'application/json')]):
+ path='/vendor/openSUSE', method='GET',
+ headers=[('Accept', 'application/json')]):
response = app.dispatch_request()
self.assertEqual(json.loads(response.data), {
- "vendor": {
- "vendor_name": "openSUSE",
- "vendor_url": "openSUSE"
- }})
+ "vendor": {
+ "vendor_name": "openSUSE",
+ "vendor_url": "openSUSE"
+ }})
self.assertEqual(response.headers['Content-Type'],
'application/json')
@@ -164,7 +165,9 @@ def test_system_json(self):
def test_package_json(self):
self.submit(compress=False, header=False)
with app.test_request_context(path='/package/sed/4.2.1/5.1.2/x86_64',
- method='GET', headers=[('Accept', 'application/json')]):
+ method='GET',
+ headers=[('Accept', 'application/json')]
+ ):
response = app.dispatch_request()
self.assertEqual(json.loads(response.data), {
"packages": [{
@@ -197,7 +200,9 @@ def test_package_json(self):
def test_distro_json(self):
self.submit(compress=False, header=False)
with app.test_request_context(path='/distro/openSUSE_12.1',
- method='GET', headers=[('Accept', 'application/json')]):
+ method='GET',
+ headers=[('Accept', 'application/json')]
+ ):
response = app.dispatch_request()
self.assertEqual(json.loads(response.data), {
"distro": {
View
@@ -50,8 +50,13 @@ def index():
# XXX think about moving this to the model
distro_packages = db_session.query(
Distro.distro_name, func.count(SubmissionPackage.pkg_name)
- ).select_from(SubmissionPackage).join(System).join(Distro
- ).group_by(Distro.distro_name).all()
+ ).select_from(
+ SubmissionPackage
+ ).join(
+ System
+ ).join(
+ Distro
+ ).group_by(Distro.distro_name).all()
# transform the list of tuples returned by SQLA into a nested JS array
distro_packages = json.dumps(distro_packages)
@@ -140,19 +145,20 @@ def package(name, version, release, arch, epoch=''):
abort(404)
pkg_statuses = db_session.query(
- SubmissionPackage.pkg_status, func.count(SubmissionPackage.pkg_status)
- ).filter_by(
+ SubmissionPackage.pkg_status,
+ func.count(SubmissionPackage.pkg_status)
+ ).filter_by(
pkg_name=name, pkg_version=version, pkg_release=release,
pkg_epoch=epoch, pkg_arch=arch
- ).group_by(
- SubmissionPackage.pkg_status).all()
+ ).group_by(
+ SubmissionPackage.pkg_status).all()
statuses = dict()
for k, v in pkg_statuses:
statuses[k] = v
print statuses
- return dict(generic_package=pkgs[0].serialize, packages=[i.serialize
- for i in pkgs], **statuses)
+ return dict(generic_package=pkgs[0].serialize,
+ packages=[i.serialize for i in pkgs], **statuses)
@app.route('/distro/<name>_<version>')

0 comments on commit 258945c

Please sign in to comment.