mirror of
https://github.com/rembo10/headphones.git
synced 2026-04-02 11:09:27 +01:00
pep: fix E302
This commit is contained in:
3
.pep8
3
.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
|
||||
@@ -94,6 +94,7 @@ MIRRORLIST = ["musicbrainz.org", "headphones", "custom"]
|
||||
|
||||
UMASK = None
|
||||
|
||||
|
||||
def initialize(config_file):
|
||||
with INIT_LOCK:
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from headphones.unittestcompat import TestCase
|
||||
|
||||
import headphones.albumart
|
||||
|
||||
|
||||
# no tests...
|
||||
class AlbumArtTest(TestCase):
|
||||
def test_nothing(self):
|
||||
|
||||
@@ -15,6 +15,7 @@ def bool_int(value):
|
||||
value = 0
|
||||
return int(bool(value))
|
||||
|
||||
|
||||
class path(str):
|
||||
"""Internal 'marker' type for paths in config."""
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
import unittestcompat
|
||||
from unittestcompat import TestCase, TestArgs
|
||||
|
||||
|
||||
class ConfigApiTest(TestCase):
|
||||
""" Common tests for headphones.Config
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -25,6 +25,7 @@ class NewzbinAPIThrottled(HeadphonesException):
|
||||
Newzbin has throttled us, deal with it
|
||||
"""
|
||||
|
||||
|
||||
class SoftChrootError(HeadphonesException):
|
||||
"""
|
||||
Fatal errors in SoftChroot module
|
||||
|
||||
@@ -34,6 +34,7 @@ from enum import Enum
|
||||
|
||||
__author__ = "Andrzej Ciarkowski <andrzej.ciarkowski@gmail.com>"
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
from headphones.exceptions import SoftChrootError
|
||||
|
||||
|
||||
class SoftChroot(object):
|
||||
""" SoftChroot provides SOFT chrooting for UI
|
||||
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -29,6 +29,7 @@ import headphones
|
||||
|
||||
_session_id = None
|
||||
|
||||
|
||||
def addTorrent(link, data=None):
|
||||
method = 'torrent-add'
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user