PyLint tweaks.

Added .pylint-ignores patchfile, with waived PyLint warnings
This commit is contained in:
sneakypete81 2013-07-28 18:40:27 +01:00
parent 3e5ba6ae28
commit d8e874aad6
8 changed files with 250 additions and 12 deletions

View file

@ -0,0 +1,224 @@
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./api_album.py /tmp/pylint_iHIz1e/api_album.py
--- ./api_album.py 2013-07-28 18:32:55.587158750 +0100
+++ /tmp/pylint_iHIz1e/api_album.py 2013-07-28 18:32:52.783144848 +0100
@@ -1,6 +1,6 @@
from .objects import Album
-class ApiAlbums(object):
+class ApiAlbums(object): # pylint: disable=R0903,C0111
def __init__(self, client):
self._client = client
@@ -9,7 +9,7 @@
results = self._client.get("/albums/list.json", **kwds)["result"]
return [Album(self._client, album) for album in results]
-class ApiAlbum(object):
+class ApiAlbum(object): # pylint: disable=C0111
def __init__(self, client):
self._client = client
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./api_photo.py /tmp/pylint_iHIz1e/api_photo.py
--- ./api_photo.py 2013-07-28 18:32:55.587158750 +0100
+++ /tmp/pylint_iHIz1e/api_photo.py 2013-07-28 18:32:52.787144864 +0100
@@ -17,7 +17,7 @@
ids.append(photo)
return ids
-class ApiPhotos(object):
+class ApiPhotos(object): # pylint: disable=C0111
def __init__(self, client):
self._client = client
@@ -51,7 +51,7 @@
raise TroveboxError("Delete response returned False")
return True
-class ApiPhoto(object):
+class ApiPhoto(object): # pylint: disable=C0111
def __init__(self, client):
self._client = client
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./api_tag.py /tmp/pylint_iHIz1e/api_tag.py
--- ./api_tag.py 2013-07-28 18:32:55.587158750 +0100
+++ /tmp/pylint_iHIz1e/api_tag.py 2013-07-28 18:32:52.787144864 +0100
@@ -1,6 +1,6 @@
from .objects import Tag
-class ApiTags(object):
+class ApiTags(object): # pylint: disable=R0903,C0111
def __init__(self, client):
self._client = client
@@ -9,7 +9,7 @@
results = self._client.get("/tags/list.json", **kwds)["result"]
return [Tag(self._client, tag) for tag in results]
-class ApiTag(object):
+class ApiTag(object): # pylint: disable=C0111
def __init__(self, client):
self._client = client
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./config.py /tmp/pylint_iHIz1e/config.py
--- ./config.py 2013-07-28 18:32:55.587158750 +0100
+++ /tmp/pylint_iHIz1e/config.py 2013-07-28 18:32:52.787144864 +0100
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import os
try:
- from configparser import ConfigParser # Python3
+ from configparser import ConfigParser # Python3 # pylint: disable=F0401
except ImportError:
from ConfigParser import SafeConfigParser as ConfigParser # Python2
try:
@@ -9,8 +9,8 @@
except ImportError:
import StringIO as io # Python2
-class Config(object):
- def __init__(self, config_file, host,
+class Config(object): # pylint: disable=R0903,C0111
+ def __init__(self, config_file, host, # pylint: disable=R0913
consumer_key, consumer_secret,
token, token_secret):
if host is None:
@@ -65,7 +65,7 @@
parser = ConfigParser()
parser.optionxform = str # Case-sensitive options
try:
- parser.read_file(buf) # Python3
+ parser.read_file(buf) # Python3 # pylint: disable=E1103
except AttributeError:
parser.readfp(buf) # Python2
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./http.py /tmp/pylint_iHIz1e/http.py
--- ./http.py 2013-07-28 18:32:55.591158774 +0100
+++ /tmp/pylint_iHIz1e/http.py 2013-07-28 18:32:52.787144864 +0100
@@ -4,18 +4,18 @@
import requests_oauthlib
import logging
try:
- from urllib.parse import urlunparse # Python3
+ from urllib.parse import urlunparse # Python3 # pylint: disable=F0401,E0611
except ImportError:
from urlparse import urlunparse # Python2
from .objects import TroveboxObject
-from .errors import *
+from .errors import * # pylint: disable=W0401
from .config import Config
if sys.version < '3':
- TEXT_TYPE = unicode
+ TEXT_TYPE = unicode # pylint: disable=C0103
else:
- TEXT_TYPE = str
+ TEXT_TYPE = str # pylint: disable=C0103
DUPLICATE_RESPONSE = {"code": 409,
"message": "This photo already exists"}
@@ -32,7 +32,7 @@
This should be used to ensure that your application will continue to work
even if the Trovebox API is updated to a new revision.
"""
- def __init__(self, config_file=None, host=None,
+ def __init__(self, config_file=None, host=None, # pylint: disable=R0913
consumer_key='', consumer_secret='',
token='', token_secret='', api_version=None):
self._api_version = api_version
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./__init__.py /tmp/pylint_iHIz1e/__init__.py
--- ./__init__.py 2013-07-28 18:32:55.591158774 +0100
+++ /tmp/pylint_iHIz1e/__init__.py 2013-07-28 18:33:03.527198125 +0100
@@ -1,5 +1,5 @@
from .http import Http
-from .errors import *
+from .errors import * # pylint: disable=W0401
from ._version import __version__
from . import api_photo
from . import api_tag
@@ -19,7 +19,7 @@
This should be used to ensure that your application will continue to work
even if the Trovebox API is updated to a new revision.
"""
- def __init__(self, config_file=None, host=None,
+ def __init__(self, config_file=None, host=None, # pylint: disable=R0913
consumer_key='', consumer_secret='',
token='', token_secret='',
api_version=None):
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./main.py /tmp/pylint_iHIz1e/main.py
--- ./main.py 2013-07-28 18:32:55.591158774 +0100
+++ /tmp/pylint_iHIz1e/main.py 2013-07-28 18:32:52.787144864 +0100
@@ -23,7 +23,7 @@
#################################################################
-def main(args=sys.argv[1:]):
+def main(args=sys.argv[1:]): # pylint: disable=R0912,C0111
usage = "%prog --help"
parser = OptionParser(usage, add_help_option=False)
parser.add_option('-c', '--config', help="Configuration file to use",
@@ -81,13 +81,13 @@
sys.exit(1)
if options.method == "GET":
- result = client.get(options.endpoint, process_response=False,
+ result = client.get(options.endpoint, process_response=False, # pylint: disable=W0142
**params)
else:
params, files = extract_files(params)
- result = client.post(options.endpoint, process_response=False,
+ result = client.post(options.endpoint, process_response=False, # pylint: disable=W0142
files=files, **params)
- for f in files:
+ for f in files: # pylint: disable=C0103
files[f].close()
if options.verbose:
diff --unified --recursive '--exclude=.pylint-ignores.patch' ./objects.py /tmp/pylint_iHIz1e/objects.py
--- ./objects.py 2013-07-28 18:32:55.591158774 +0100
+++ /tmp/pylint_iHIz1e/objects.py 2013-07-28 18:32:52.787144864 +0100
@@ -1,14 +1,14 @@
try:
- from urllib.parse import quote # Python3
+ from urllib.parse import quote # Python3 # pylint: disable=F0401,E0611
except ImportError:
from urllib import quote # Python2
from .errors import TroveboxError
-class TroveboxObject(object):
+class TroveboxObject(object): # pylint: disable=R0903
""" Base object supporting the storage of custom fields as attributes """
def __init__(self, trovebox, json_dict):
- self.id = None
+ self.id = None # pylint: disable=C0103
self.name = None
self._trovebox = trovebox
self._json_dict = json_dict
@@ -54,7 +54,7 @@
return self._json_dict
-class Photo(TroveboxObject):
+class Photo(TroveboxObject): # pylint: disable=C0111
def delete(self, **kwds):
"""
Delete this photo.
@@ -144,7 +144,7 @@
self._replace_fields(new_dict)
-class Tag(TroveboxObject):
+class Tag(TroveboxObject): # pylint: disable=C0111
def delete(self, **kwds):
"""
Delete this tag.
@@ -165,7 +165,7 @@
self._replace_fields(new_dict)
-class Album(TroveboxObject):
+class Album(TroveboxObject): # pylint: disable=C0111
def __init__(self, trovebox, json_dict):
self.photos = None
self.cover = None

View file

@ -1,6 +1,6 @@
from .objects import Album from .objects import Album
class ApiAlbums: class ApiAlbums(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client
@ -9,7 +9,7 @@ class ApiAlbums:
results = self._client.get("/albums/list.json", **kwds)["result"] results = self._client.get("/albums/list.json", **kwds)["result"]
return [Album(self._client, album) for album in results] return [Album(self._client, album) for album in results]
class ApiAlbum: class ApiAlbum(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client
@ -30,12 +30,15 @@ class ApiAlbum:
return album.delete(**kwds) return album.delete(**kwds)
def form(self, album, **kwds): def form(self, album, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def add_photos(self, album, photos, **kwds): def add_photos(self, album, photos, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def remove_photos(self, album, photos, **kwds): def remove_photos(self, album, photos, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def update(self, album, **kwds): def update(self, album, **kwds):

View file

@ -17,7 +17,7 @@ def extract_ids(photos):
ids.append(photo) ids.append(photo)
return ids return ids
class ApiPhotos: class ApiPhotos(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client
@ -51,7 +51,7 @@ class ApiPhotos:
raise TroveboxError("Delete response returned False") raise TroveboxError("Delete response returned False")
return True return True
class ApiPhoto: class ApiPhoto(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client
@ -72,9 +72,11 @@ class ApiPhoto:
return photo.edit(**kwds) return photo.edit(**kwds)
def replace(self, photo, photo_file, **kwds): def replace(self, photo, photo_file, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def replace_encoded(self, photo, photo_file, **kwds): def replace_encoded(self, photo, photo_file, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def update(self, photo, **kwds): def update(self, photo, **kwds):
@ -114,6 +116,7 @@ class ApiPhoto:
return Photo(self._client, result) return Photo(self._client, result)
def dynamic_url(self, photo, **kwds): def dynamic_url(self, photo, **kwds):
""" Not yet implemented """
raise NotImplementedError() raise NotImplementedError()
def next_previous(self, photo, **kwds): def next_previous(self, photo, **kwds):

View file

@ -1,6 +1,6 @@
from .objects import Tag from .objects import Tag
class ApiTags: class ApiTags(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client
@ -9,7 +9,7 @@ class ApiTags:
results = self._client.get("/tags/list.json", **kwds)["result"] results = self._client.get("/tags/list.json", **kwds)["result"]
return [Tag(self._client, tag) for tag in results] return [Tag(self._client, tag) for tag in results]
class ApiTag: class ApiTag(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client

View file

@ -9,7 +9,7 @@ try:
except ImportError: except ImportError:
import StringIO as io # Python2 import StringIO as io # Python2
class Config: class Config(object):
def __init__(self, config_file, host, def __init__(self, config_file, host,
consumer_key, consumer_secret, consumer_key, consumer_secret,
token, token_secret): token, token_secret):
@ -46,7 +46,8 @@ def get_config_path(config_file):
def read_config(config_path): def read_config(config_path):
""" """
Loads config data from the specified file path. Loads config data from the specified file path.
If config_file doesn't exist, returns an empty authentication config for localhost. If config_file doesn't exist, returns an empty authentication config
for localhost.
""" """
section = "DUMMY" section = "DUMMY"
defaults = {'host': 'localhost', defaults = {'host': 'localhost',

View file

@ -20,7 +20,7 @@ else:
DUPLICATE_RESPONSE = {"code": 409, DUPLICATE_RESPONSE = {"code": 409,
"message": "This photo already exists"} "message": "This photo already exists"}
class Http: class Http(object):
""" """
Base class to handle HTTP requests to an Trovebox server. Base class to handle HTTP requests to an Trovebox server.
If no parameters are specified, config is loaded from the default If no parameters are specified, config is loaded from the default

View file

@ -44,7 +44,7 @@ def main(args=sys.argv[1:]):
action="store_true", dest="pretty", default=False) action="store_true", dest="pretty", default=False)
parser.add_option('-v', help="Verbose output", parser.add_option('-v', help="Verbose output",
action="store_true", dest="verbose", default=False) action="store_true", dest="verbose", default=False)
parser.add_option('--version', help="Display the current version information", parser.add_option('--version', help="Display the current version",
action="store_true") action="store_true")
parser.add_option('--help', help='show this help message', parser.add_option('--help', help='show this help message',
action="store_true") action="store_true")
@ -107,7 +107,8 @@ def main(args=sys.argv[1:]):
def extract_files(params): def extract_files(params):
""" """
Extract filenames from the "photo" parameter, so they can be uploaded, returning (updated_params, files). Extract filenames from the "photo" parameter so they can be uploaded,
returning (updated_params, files).
Uses the same technique as the Trovebox PHP commandline tool: Uses the same technique as the Trovebox PHP commandline tool:
* Filename can only be in the "photo" parameter * Filename can only be in the "photo" parameter
* Filename must be prefixed with "@" * Filename must be prefixed with "@"

View file

@ -5,7 +5,7 @@ except ImportError:
from .errors import TroveboxError from .errors import TroveboxError
class TroveboxObject: class TroveboxObject(object):
""" Base object supporting the storage of custom fields as attributes """ """ Base object supporting the storage of custom fields as attributes """
def __init__(self, trovebox, json_dict): def __init__(self, trovebox, json_dict):
self.id = None self.id = None
@ -75,9 +75,11 @@ class Photo(TroveboxObject):
return result["markup"] return result["markup"]
def replace(self, photo_file, **kwds): def replace(self, photo_file, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def replace_encoded(self, photo_file, **kwds): def replace_encoded(self, photo_file, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def update(self, **kwds): def update(self, **kwds):
@ -96,6 +98,7 @@ class Photo(TroveboxObject):
self._replace_fields(new_dict) self._replace_fields(new_dict)
def dynamic_url(self, **kwds): def dynamic_url(self, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def next_previous(self, **kwds): def next_previous(self, **kwds):
@ -194,12 +197,15 @@ class Album(TroveboxObject):
return result return result
def form(self, **kwds): def form(self, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def add_photos(self, photos, **kwds): def add_photos(self, photos, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def remove_photos(self, photos, **kwds): def remove_photos(self, photos, **kwds):
""" Not implemented yet """
raise NotImplementedError() raise NotImplementedError()
def update(self, **kwds): def update(self, **kwds):