From b6a3d68417f7c0c9fd556c8b0ea3c840f99fb54d Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Mon, 6 Jun 2016 16:40:51 +0200 Subject: [PATCH 1/2] #1084 cleaning imports --- webcompat/db/__init__.py | 2 -- webcompat/issues.py | 1 - webcompat/views.py | 1 - 3 files changed, 4 deletions(-) diff --git a/webcompat/db/__init__.py b/webcompat/db/__init__.py index a614d07bb..c9ac8b934 100644 --- a/webcompat/db/__init__.py +++ b/webcompat/db/__init__.py @@ -7,9 +7,7 @@ import os from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column -from sqlalchemy import Integer from sqlalchemy import String from sqlalchemy.orm import scoped_session from sqlalchemy.orm import sessionmaker diff --git a/webcompat/issues.py b/webcompat/issues.py index 122e2c172..81e4e43e5 100644 --- a/webcompat/issues.py +++ b/webcompat/issues.py @@ -9,7 +9,6 @@ import json -from webcompat import app from webcompat import github from webcompat.form import build_formdata from webcompat.helpers import proxy_request diff --git a/webcompat/views.py b/webcompat/views.py index 0e62f8680..a1cce187a 100644 --- a/webcompat/views.py +++ b/webcompat/views.py @@ -33,7 +33,6 @@ from webcompat import app from webcompat import github from webcompat.api.endpoints import get_rate_limit -from webcompat.api.uploads import upload @app.teardown_appcontext From 45cd6c6f578f8b77f9fc73f6385346f40f4dc831 Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Mon, 6 Jun 2016 16:49:08 +0200 Subject: [PATCH 2/2] #1084 fixing syntax issues --- labels.py | 20 ++++++++++---------- run.py | 1 - webcompat/api/uploads.py | 5 +++-- webcompat/error_handlers/__init__.py | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/labels.py b/labels.py index 6402abc7e..2212af201 100644 --- a/labels.py +++ b/labels.py @@ -28,9 +28,9 @@ def get_issue_labels(labels_uri): def create_label(labels): '''Create a label in the user repo''' response = requests.post( - USER_LABELS_URI, - json.dumps(labels), - headers=AUTH_HEADERS) + USER_LABELS_URI, + json.dumps(labels), + headers=AUTH_HEADERS) if not response.status_code == 201: response.raise_for_status() @@ -45,28 +45,28 @@ def delete_label(name): def main(): '''Duplicate webcompat test repo labels in user test repo''' - #check if the user repo is a webcompat repo + # check if the user repo is a webcompat repo if (ISSUES_URI == "webcompat/webcompat-tests" or ISSUES_URI == "webcompat/webcompat.com"): sys.exit("Error: Attempting to change a webcompat repo") try: - #get all existing labels from the user issues repo + # get all existing labels from the user issues repo user_labels = get_issue_labels(USER_LABELS_URI) - #delete all existing labels from the user issues repo + # delete all existing labels from the user issues repo for label in user_labels: delete_label(label.get('name')) - #get all labels from the webcompat tests repo + # get all labels from the webcompat tests repo webcompat_labels = get_issue_labels(WEBCOMPAT_LABELS_URI) - #re-create labels in user issues repo + # re-create labels in user issues repo for label in webcompat_labels: data = {"name": label.get('name'), "color": label.get('color')} create_label(data) sys.exit(0) except requests.exceptions.HTTPError as e: - #handles exceptions occuring due to undesired response status code + # handles exceptions occuring due to undesired response status code sys.exit("Error: {}".format(e)) except requests.exceptions.RequestException as e: - #handles all other exceptions + # handles all other exceptions sys.exit("Error: {}".format(e)) diff --git a/run.py b/run.py index 6046b4856..802111a45 100644 --- a/run.py +++ b/run.py @@ -7,7 +7,6 @@ import argparse import pkg_resources from pkg_resources import DistributionNotFound, VersionConflict -import subprocess import sys IMPORT_ERROR = ''' diff --git a/webcompat/api/uploads.py b/webcompat/api/uploads.py index a3d7c8534..8afbe2fa9 100644 --- a/webcompat/api/uploads.py +++ b/webcompat/api/uploads.py @@ -29,6 +29,7 @@ class Upload(object): + '''Class that abstracts over saving image and screenshot uploads. It performs a simple extension-based validation before saving to the @@ -95,8 +96,8 @@ def save(self): file_dest = 'jpg'.join(file_dest.rsplit('png', 1)) # If animated GIF, aka duration > 0, add save_all parameter if (self.image_object.format == 'GIF' and - self.image_object.info['duration'] > 0): - save_parameters['save_all'] = True + self.image_object.info['duration'] > 0): + save_parameters['save_all'] = True # unpacking save_parameters self.image_object.save(file_dest, **save_parameters) diff --git a/webcompat/error_handlers/__init__.py b/webcompat/error_handlers/__init__.py index 49666c644..ecc897e0c 100644 --- a/webcompat/error_handlers/__init__.py +++ b/webcompat/error_handlers/__init__.py @@ -39,8 +39,8 @@ def error_response(request, code): def api_call(request): '''Helper method to check if the request originates from an API call''' if (request.path.startswith('/api/') and - request.accept_mimetypes.accept_json and - not request.accept_mimetypes.accept_html): + request.accept_mimetypes.accept_json and + not request.accept_mimetypes.accept_html): return True else: return False