Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ install:
script: tox

after_script:
# Install dependencies for Pylint
- pip install requests requests-oauthlib

# Run Pylint
# (for information only, any errors don't affect the Travis result)
- pylint --use-ignore-patch=y openphoto
- pylint --use-ignore-patch=y tests

- pylint --use-ignore-patch=y trovebox
9 changes: 4 additions & 5 deletions .travis/install_pylint
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Until the --use-ignore-patch makes it into pylint upstream, we need to
# download and install from sneakypete81's pylint fork
HG_HASH=16de8b9518be

wget https://bitbucket.org/sneakypete81/pylint/get/$HG_HASH.zip
unzip $HG_HASH.zip
cd sneakypete81-pylint-$HG_HASH
wget https://bitbucket.org/sneakypete81/pylint/get/use_ignore_patch.zip
unzip use_ignore_patch.zip
cd sneakypete81-pylint-*
python setup.py install

cd ..
rm -r sneakypete81-pylint-$HG_HASH
rm -r sneakypete81-pylint-*
230 changes: 230 additions & 0 deletions trovebox/.pylint-ignores.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
diff --unified --recursive '--exclude=.pylint-ignores.patch' original/api_album.py patched/api_album.py
--- original/api_album.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/api_album.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,6 +1,7 @@
+ # pylint: disable=C0111
from .objects import Album

-class ApiAlbums(object):
+class ApiAlbums(object): # pylint: disable=R0903,C0111
def __init__(self, client):
self._client = client

@@ -9,7 +10,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' original/api_photo.py patched/api_photo.py
--- original/api_photo.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/api_photo.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,3 +1,4 @@
+ # pylint: disable=C0111
import base64

from .errors import TroveboxError
@@ -17,7 +18,7 @@
ids.append(photo)
return ids

-class ApiPhotos(object):
+class ApiPhotos(object): # pylint: disable=C0111
def __init__(self, client):
self._client = client

@@ -51,7 +52,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' original/api_tag.py patched/api_tag.py
--- original/api_tag.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/api_tag.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,6 +1,7 @@
+ # pylint: disable=C0111
from .objects import Tag

-class ApiTags(object):
+class ApiTags(object): # pylint: disable=R0903,C0111
def __init__(self, client):
self._client = client

@@ -9,7 +10,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' original/config.py patched/config.py
--- original/config.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/config.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,7 +1,8 @@
+ # pylint: disable=C0111
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 +10,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 +66,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' original/errors.py patched/errors.py
--- original/errors.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/errors.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,3 +1,4 @@
+ # pylint: disable=C0111
class TroveboxError(Exception):
""" Indicates that an Trovebox operation failed """
pass
diff --unified --recursive '--exclude=.pylint-ignores.patch' original/http.py patched/http.py
--- original/http.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/http.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,21 +1,22 @@
+ # pylint: disable=C0111
from __future__ import unicode_literals
import sys
import requests
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 +33,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' original/__init__.py patched/__init__.py
--- original/__init__.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/__init__.py 2013-08-07 21:13:59.879967978 +0100
@@ -1,5 +1,6 @@
+ # pylint: disable=C0111
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 +20,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' original/main.py patched/main.py
--- original/main.py 2013-08-07 21:13:32.151830000 +0100
+++ patched/main.py 2013-08-07 21:13:59.883967994 +0100
@@ -1,3 +1,4 @@
+ # pylint: disable=C0111
#!/usr/bin/env python
import os
import sys
@@ -23,7 +24,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 +82,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' original/objects.py patched/objects.py
--- original/objects.py 2013-08-07 21:13:32.155830000 +0100
+++ patched/objects.py 2013-08-07 21:13:59.883967994 +0100
@@ -1,14 +1,15 @@
+ # pylint: disable=C0111
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
diff --unified --recursive '--exclude=.pylint-ignores.patch' original/_version.py patched/_version.py
--- original/_version.py 2013-08-07 21:12:22.487484000 +0100
+++ patched/_version.py 2013-08-07 21:14:05.947998060 +0100
@@ -1 +1,2 @@
+ # pylint: disable=C0111
__version__ = "0.4"
7 changes: 5 additions & 2 deletions trovebox/api_album.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .objects import Album

class ApiAlbums:
class ApiAlbums(object):
def __init__(self, client):
self._client = client

Expand All @@ -9,7 +9,7 @@ def list(self, **kwds):
results = self._client.get("/albums/list.json", **kwds)["result"]
return [Album(self._client, album) for album in results]

class ApiAlbum:
class ApiAlbum(object):
def __init__(self, client):
self._client = client

Expand All @@ -30,12 +30,15 @@ def delete(self, album, **kwds):
return album.delete(**kwds)

def form(self, album, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def add_photos(self, album, photos, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def remove_photos(self, album, photos, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def update(self, album, **kwds):
Expand Down
7 changes: 5 additions & 2 deletions trovebox/api_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_ids(photos):
ids.append(photo)
return ids

class ApiPhotos:
class ApiPhotos(object):
def __init__(self, client):
self._client = client

Expand Down Expand Up @@ -51,7 +51,7 @@ def delete(self, photos, **kwds):
raise TroveboxError("Delete response returned False")
return True

class ApiPhoto:
class ApiPhoto(object):
def __init__(self, client):
self._client = client

Expand All @@ -72,9 +72,11 @@ def edit(self, photo, **kwds):
return photo.edit(**kwds)

def replace(self, photo, photo_file, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def replace_encoded(self, photo, photo_file, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def update(self, photo, **kwds):
Expand Down Expand Up @@ -114,6 +116,7 @@ def upload_encoded(self, photo_file, **kwds):
return Photo(self._client, result)

def dynamic_url(self, photo, **kwds):
""" Not yet implemented """
raise NotImplementedError()

def next_previous(self, photo, **kwds):
Expand Down
4 changes: 2 additions & 2 deletions trovebox/api_tag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .objects import Tag

class ApiTags:
class ApiTags(object):
def __init__(self, client):
self._client = client

Expand All @@ -9,7 +9,7 @@ def list(self, **kwds):
results = self._client.get("/tags/list.json", **kwds)["result"]
return [Tag(self._client, tag) for tag in results]

class ApiTag:
class ApiTag(object):
def __init__(self, client):
self._client = client

Expand Down
5 changes: 3 additions & 2 deletions trovebox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
import StringIO as io # Python2

class Config:
class Config(object):
def __init__(self, config_file, host,
consumer_key, consumer_secret,
token, token_secret):
Expand Down Expand Up @@ -46,7 +46,8 @@ def get_config_path(config_file):
def read_config(config_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"
defaults = {'host': 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion trovebox/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DUPLICATE_RESPONSE = {"code": 409,
"message": "This photo already exists"}

class Http:
class Http(object):
"""
Base class to handle HTTP requests to an Trovebox server.
If no parameters are specified, config is loaded from the default
Expand Down
5 changes: 3 additions & 2 deletions trovebox/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main(args=sys.argv[1:]):
action="store_true", dest="pretty", default=False)
parser.add_option('-v', help="Verbose output",
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")
parser.add_option('--help', help='show this help message',
action="store_true")
Expand Down Expand Up @@ -107,7 +107,8 @@ def main(args=sys.argv[1:]):

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:
* Filename can only be in the "photo" parameter
* Filename must be prefixed with "@"
Expand Down
Loading