mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -07:00
Fix flake8-quotes Q000 Remove bad quotes
This commit is contained in:
parent
99159acd80
commit
9f52406d45
5 changed files with 26 additions and 26 deletions
|
@ -19,6 +19,6 @@ Example usage:
|
|||
from .exceptions import DelugeRPCError
|
||||
|
||||
|
||||
__title__ = "synchronous-deluge"
|
||||
__version__ = "0.1"
|
||||
__author__ = "Christian Dale"
|
||||
__title__ = 'synchronous-deluge'
|
||||
__version__ = '0.1'
|
||||
__author__ = 'Christian Dale'
|
||||
|
|
|
@ -9,7 +9,7 @@ from .exceptions import DelugeRPCError
|
|||
from .protocol import DelugeRPCRequest, DelugeRPCResponse
|
||||
from .transfer import DelugeTransfer
|
||||
|
||||
__all__ = ["DelugeClient"]
|
||||
__all__ = ['DelugeClient']
|
||||
|
||||
RPC_RESPONSE = 1
|
||||
RPC_ERROR = 2
|
||||
|
@ -24,35 +24,35 @@ class DelugeClient(object):
|
|||
self._request_counter = 0
|
||||
|
||||
def _get_local_auth(self):
|
||||
username = password = ""
|
||||
username = password = ''
|
||||
if platform.system() in ('Windows', 'Microsoft'):
|
||||
app_data_path = os.environ.get("APPDATA")
|
||||
app_data_path = os.environ.get('APPDATA')
|
||||
if not app_data_path:
|
||||
from six.moves import winreg
|
||||
hkey = winreg.OpenKey(
|
||||
winreg.HKEY_CURRENT_USER,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
|
||||
'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders',
|
||||
)
|
||||
app_data_reg = winreg.QueryValueEx(hkey, "AppData")
|
||||
app_data_reg = winreg.QueryValueEx(hkey, 'AppData')
|
||||
app_data_path = app_data_reg[0]
|
||||
winreg.CloseKey(hkey)
|
||||
|
||||
auth_file = os.path.join(app_data_path, "deluge", "auth")
|
||||
auth_file = os.path.join(app_data_path, 'deluge', 'auth')
|
||||
else:
|
||||
from xdg.BaseDirectory import save_config_path
|
||||
try:
|
||||
auth_file = os.path.join(save_config_path("deluge"), "auth")
|
||||
auth_file = os.path.join(save_config_path('deluge'), 'auth')
|
||||
except OSError:
|
||||
return username, password
|
||||
|
||||
if os.path.exists(auth_file):
|
||||
for line in open(auth_file):
|
||||
if line.startswith("#"):
|
||||
if line.startswith('#'):
|
||||
# This is a comment line
|
||||
continue
|
||||
line = line.strip()
|
||||
try:
|
||||
lsplit = line.split(":")
|
||||
lsplit = line.split(':')
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
@ -63,13 +63,13 @@ class DelugeClient(object):
|
|||
else:
|
||||
continue
|
||||
|
||||
if username == "localclient":
|
||||
if username == 'localclient':
|
||||
return username, password
|
||||
|
||||
return "", ""
|
||||
return '', ''
|
||||
|
||||
def _create_module_method(self, module, method):
|
||||
fullname = "{0}.{1}".format(module, method)
|
||||
fullname = '{0}.{1}'.format(module, method)
|
||||
|
||||
def func(obj, *args, **kwargs):
|
||||
return self.remote_call(fullname, *args, **kwargs)
|
||||
|
@ -80,18 +80,18 @@ class DelugeClient(object):
|
|||
|
||||
def _introspect(self):
|
||||
def splitter(value):
|
||||
return value.split(".")
|
||||
return value.split('.')
|
||||
|
||||
self.modules = []
|
||||
|
||||
methods = self.remote_call("daemon.get_method_list").get()
|
||||
methods = self.remote_call('daemon.get_method_list').get()
|
||||
methodmap = defaultdict(dict)
|
||||
|
||||
for module, method in imap(splitter, methods):
|
||||
methodmap[module][method] = self._create_module_method(module, method)
|
||||
|
||||
for module, methods in methodmap.items():
|
||||
clsname = "DelugeModule{0}".format(module.capitalize())
|
||||
clsname = 'DelugeModule{0}'.format(module.capitalize())
|
||||
cls = type(clsname, (), methods)
|
||||
setattr(self, module, cls())
|
||||
self.modules.append(module)
|
||||
|
@ -133,7 +133,7 @@ class DelugeClient(object):
|
|||
self._request_counter += 1
|
||||
return response
|
||||
|
||||
def connect(self, host="127.0.0.1", port=58846, username="", password=""):
|
||||
def connect(self, host='127.0.0.1', port=58846, username='', password=''):
|
||||
"""Connect to a daemon process.
|
||||
|
||||
:param host: str, the hostname of the daemon
|
||||
|
@ -145,11 +145,11 @@ class DelugeClient(object):
|
|||
self.transfer.connect((host, port))
|
||||
|
||||
# Attempt to fetch local auth info if needed
|
||||
if not username and host in ("127.0.0.1", "localhost"):
|
||||
if not username and host in ('127.0.0.1', 'localhost'):
|
||||
username, password = self._get_local_auth()
|
||||
|
||||
# Authenticate
|
||||
self.remote_call("daemon.login", username, password).get()
|
||||
self.remote_call('daemon.login', username, password).get()
|
||||
|
||||
# Introspect available methods
|
||||
self._introspect()
|
||||
|
|
|
@ -8,4 +8,4 @@ class DelugeRPCError(Exception):
|
|||
self.traceback = traceback
|
||||
|
||||
def __str__(self):
|
||||
return "{0}: {1}: {2}".format(self.__class__.__name__, self.name, self.msg)
|
||||
return '{0}: {1}: {2}'.format(self.__class__.__name__, self.name, self.msg)
|
||||
|
|
|
@ -6,7 +6,7 @@ import zlib
|
|||
|
||||
import rencode
|
||||
|
||||
__all__ = ["DelugeTransfer"]
|
||||
__all__ = ['DelugeTransfer']
|
||||
|
||||
|
||||
class DelugeTransfer(object):
|
||||
|
@ -33,7 +33,7 @@ class DelugeTransfer(object):
|
|||
payload = zlib.compress(rencode.dumps(data))
|
||||
self.conn.sendall(payload)
|
||||
|
||||
buf = b""
|
||||
buf = b''
|
||||
|
||||
while True:
|
||||
data = self.conn.recv(1024)
|
||||
|
|
|
@ -94,8 +94,8 @@ class UTorrentClient(object):
|
|||
def setprops(self, cur_hash, **kvpairs):
|
||||
params = [('action', 'setprops'), ('hash', cur_hash)]
|
||||
for k, v in iteritems(kvpairs):
|
||||
params.append(("s", k))
|
||||
params.append(("v", v))
|
||||
params.append(('s', k))
|
||||
params.append(('v', v))
|
||||
|
||||
return self._action(params)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue