From bc54b5abaf2c13fd8b41ecf59f87c64d389f161d Mon Sep 17 00:00:00 2001 From: satreix Date: Thu, 25 Feb 2016 12:22:51 +0100 Subject: [PATCH] pep: fix E302 --- .pep8 | 3 +-- headphones/__init__.py | 1 + headphones/albumart_test.py | 1 + headphones/config.py | 1 + headphones/config_test.py | 1 + headphones/deluge.py | 10 ++++++++++ headphones/exceptions.py | 1 + headphones/pathrender.py | 9 +++++++++ headphones/softchroot.py | 1 + headphones/softchroot_test.py | 1 + headphones/transmission.py | 1 + headphones/unittestcompat.py | 2 ++ headphones/webserve.py | 1 + 13 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.pep8 b/.pep8 index 9dc3362c..b27f4eda 100644 --- a/.pep8 +++ b/.pep8 @@ -10,8 +10,7 @@ # E261 at least two spaces before inline comment # E262 inline comment should start with '# ' # E265 block comment should start with '# ' -# E302 expected 2 blank lines, found 1 # E501 line too long (312 > 160 characters) # E502 the backslash is redundant between brackets -ignore = E111,E121,E122,E123,E124,E125,E126,E127,E128,E261,E262,E265,E302,E501,E502 +ignore = E111,E121,E122,E123,E124,E125,E126,E127,E128,E261,E262,E265,E501,E502 max-line-length = 160 \ No newline at end of file diff --git a/headphones/__init__.py b/headphones/__init__.py index 92b274a9..4b36acf7 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -94,6 +94,7 @@ MIRRORLIST = ["musicbrainz.org", "headphones", "custom"] UMASK = None + def initialize(config_file): with INIT_LOCK: diff --git a/headphones/albumart_test.py b/headphones/albumart_test.py index f18b11e3..e1b80c02 100644 --- a/headphones/albumart_test.py +++ b/headphones/albumart_test.py @@ -4,6 +4,7 @@ from headphones.unittestcompat import TestCase import headphones.albumart + # no tests... class AlbumArtTest(TestCase): def test_nothing(self): diff --git a/headphones/config.py b/headphones/config.py index 6b34bdd1..dd1ae9b6 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -15,6 +15,7 @@ def bool_int(value): value = 0 return int(bool(value)) + class path(str): """Internal 'marker' type for paths in config.""" diff --git a/headphones/config_test.py b/headphones/config_test.py index e321d4af..1cd5367f 100644 --- a/headphones/config_test.py +++ b/headphones/config_test.py @@ -5,6 +5,7 @@ import re import unittestcompat from unittestcompat import TestCase, TestArgs + class ConfigApiTest(TestCase): """ Common tests for headphones.Config diff --git a/headphones/deluge.py b/headphones/deluge.py index 9f999924..30d4b2f5 100644 --- a/headphones/deluge.py +++ b/headphones/deluge.py @@ -49,6 +49,7 @@ import traceback delugeweb_auth = {} delugeweb_url = '' + def addTorrent(link, data=None): try: result = {} @@ -144,6 +145,7 @@ def addTorrent(link, data=None): formatted_lines = traceback.format_exc().splitlines() logger.error('; '.join(formatted_lines)) + def getTorrentFolder(result): logger.debug('Deluge: Get torrent folder name') if not any(delugeweb_auth): @@ -190,6 +192,7 @@ def getTorrentFolder(result): except Exception as e: logger.debug('Deluge: Could not get torrent folder name: %s' % str(e)) + def removeTorrent(torrentid, remove_data=False): if not any(delugeweb_auth): @@ -207,6 +210,7 @@ def removeTorrent(torrentid, remove_data=False): return result + def _get_auth(): logger.debug('Deluge: Authenticating...') global delugeweb_auth, delugeweb_url @@ -289,6 +293,7 @@ def _get_auth(): return auth + def _add_torrent_magnet(result): logger.debug('Deluge: Adding magnet') if not any(delugeweb_auth): @@ -321,6 +326,7 @@ def _add_torrent_url(result): logger.error('Deluge: Adding torrent URL failed: %s' % str(e)) ''' + def _add_torrent_file(result): logger.debug('Deluge: Adding file') if not any(delugeweb_auth): @@ -339,6 +345,7 @@ def _add_torrent_file(result): formatted_lines = traceback.format_exc().splitlines() logger.error('; '.join(formatted_lines)) + def setTorrentLabel(result): logger.debug('Deluge: Setting label') label = headphones.CONFIG.DELUGE_LABEL @@ -383,6 +390,7 @@ def setTorrentLabel(result): return not json.loads(response.text)['error'] + def setSeedRatio(result): logger.debug('Deluge: Setting seed ratio') if not any(delugeweb_auth): @@ -406,6 +414,7 @@ def setSeedRatio(result): return True + def setTorrentPath(result): logger.debug('Deluge: Setting download path') if not any(delugeweb_auth): @@ -434,6 +443,7 @@ def setTorrentPath(result): return True + def setTorrentPause(result): logger.debug('Deluge: Pausing torrent') if not any(delugeweb_auth): diff --git a/headphones/exceptions.py b/headphones/exceptions.py index 107535c5..562dc8c3 100644 --- a/headphones/exceptions.py +++ b/headphones/exceptions.py @@ -25,6 +25,7 @@ class NewzbinAPIThrottled(HeadphonesException): Newzbin has throttled us, deal with it """ + class SoftChrootError(HeadphonesException): """ Fatal errors in SoftChroot module diff --git a/headphones/pathrender.py b/headphones/pathrender.py index a00a1192..afaf1b4e 100644 --- a/headphones/pathrender.py +++ b/headphones/pathrender.py @@ -34,6 +34,7 @@ from enum import Enum __author__ = "Andrzej Ciarkowski " + class _PatternElement(object): '''ABC for hierarchy of path name renderer pattern elements.''' def render(self, replacement): @@ -41,11 +42,13 @@ class _PatternElement(object): '''Format this _PatternElement into string using provided substitution dictionary.''' raise NotImplementedError() + class _Generator(_PatternElement): # pylint: disable=abstract-method '''Tagging interface for "content-generating" elements like replacement or optional block.''' pass + class _Replacement(_Generator): '''Replacement variable, eg. $title.''' def __init__(self, pattern): @@ -95,15 +98,18 @@ _OPTIONAL_END = u']' _ESCAPE_CHAR = u'\'' _REPLACEMENT_START = u'$' + def _is_replacement_valid(c): # type: (str) -> bool return c.isalnum() or c == u'_' + class _State(Enum): LITERAL = 0 ESCAPE = 1 REPLACEMENT = 2 + def _append_literal(scope, text): # type: ([_PatternElement], str) -> None '''Append literal text to the scope BUT ONLY if it's not an empty string.''' @@ -111,11 +117,13 @@ def _append_literal(scope, text): return scope.append(_LiteralText(text)) + class Warnings(Enum): '''Pattern parsing warnings, as stored withing warnings property of Pattern object after parsing.''' UNCLOSED_ESCAPE = 'Warnings.UNCLOSED_ESCAPE' UNCLOSED_OPTIONAL = 'Warnings.UNCLOSED_OPTIONAL' + def _parse_pattern(pattern, warnings): # type: (str,MutableSet[Warnings]) -> [_PatternElement] '''Parse path pattern text into list of _PatternElements, put warnings into the provided set.''' @@ -188,6 +196,7 @@ def _parse_pattern(pattern, warnings): _append_literal(root_scope, pattern[start:]) return root_scope + class Pattern(object): '''Stores preparsed rename pattern for repeated use. diff --git a/headphones/softchroot.py b/headphones/softchroot.py index 80878548..3716a035 100644 --- a/headphones/softchroot.py +++ b/headphones/softchroot.py @@ -1,6 +1,7 @@ import os from headphones.exceptions import SoftChrootError + class SoftChroot(object): """ SoftChroot provides SOFT chrooting for UI diff --git a/headphones/softchroot_test.py b/headphones/softchroot_test.py index baa56703..474969d7 100644 --- a/headphones/softchroot_test.py +++ b/headphones/softchroot_test.py @@ -6,6 +6,7 @@ from headphones.unittestcompat import TestCase, TestArgs from headphones.softchroot import SoftChroot from headphones.exceptions import SoftChrootError + class SoftChrootTest(TestCase): def test_create(self): """ create headphones.SoftChroot """ diff --git a/headphones/transmission.py b/headphones/transmission.py index 11da8989..b62e2fac 100644 --- a/headphones/transmission.py +++ b/headphones/transmission.py @@ -29,6 +29,7 @@ import headphones _session_id = None + def addTorrent(link, data=None): method = 'torrent-add' diff --git a/headphones/unittestcompat.py b/headphones/unittestcompat.py index 12a497be..0bf26c3c 100644 --- a/headphones/unittestcompat.py +++ b/headphones/unittestcompat.py @@ -14,6 +14,7 @@ _dummy = False if sys.version_info[0] == 2 and sys.version_info[1] <= 6: _dummy = True + def _d(f): def decorate(self, *args, **kw): if not _dummy: @@ -92,6 +93,7 @@ class TestCase(TC): # True indicates, that exception is handled return True + def TestArgs(*parameters): def tuplify(x): if not isinstance(x, tuple): diff --git a/headphones/webserve.py b/headphones/webserve.py index f12f47c3..9253e058 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1709,6 +1709,7 @@ class WebInterface(object): telegram = notifiers.TELEGRAM() telegram.notify("it works!", "lazers pew pew") + class Artwork(object): @cherrypy.expose def index(self):