Fix flake8-quotes Q000 Remove bad quotes

This commit is contained in:
Labrys of Knossos 2019-04-07 13:44:33 -04:00
commit 9f52406d45
5 changed files with 26 additions and 26 deletions

View file

@ -19,6 +19,6 @@ Example usage:
from .exceptions import DelugeRPCError from .exceptions import DelugeRPCError
__title__ = "synchronous-deluge" __title__ = 'synchronous-deluge'
__version__ = "0.1" __version__ = '0.1'
__author__ = "Christian Dale" __author__ = 'Christian Dale'

View file

@ -9,7 +9,7 @@ from .exceptions import DelugeRPCError
from .protocol import DelugeRPCRequest, DelugeRPCResponse from .protocol import DelugeRPCRequest, DelugeRPCResponse
from .transfer import DelugeTransfer from .transfer import DelugeTransfer
__all__ = ["DelugeClient"] __all__ = ['DelugeClient']
RPC_RESPONSE = 1 RPC_RESPONSE = 1
RPC_ERROR = 2 RPC_ERROR = 2
@ -24,35 +24,35 @@ class DelugeClient(object):
self._request_counter = 0 self._request_counter = 0
def _get_local_auth(self): def _get_local_auth(self):
username = password = "" username = password = ''
if platform.system() in ('Windows', 'Microsoft'): 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: if not app_data_path:
from six.moves import winreg from six.moves import winreg
hkey = winreg.OpenKey( hkey = winreg.OpenKey(
winreg.HKEY_CURRENT_USER, 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] app_data_path = app_data_reg[0]
winreg.CloseKey(hkey) winreg.CloseKey(hkey)
auth_file = os.path.join(app_data_path, "deluge", "auth") auth_file = os.path.join(app_data_path, 'deluge', 'auth')
else: else:
from xdg.BaseDirectory import save_config_path from xdg.BaseDirectory import save_config_path
try: try:
auth_file = os.path.join(save_config_path("deluge"), "auth") auth_file = os.path.join(save_config_path('deluge'), 'auth')
except OSError: except OSError:
return username, password return username, password
if os.path.exists(auth_file): if os.path.exists(auth_file):
for line in open(auth_file): for line in open(auth_file):
if line.startswith("#"): if line.startswith('#'):
# This is a comment line # This is a comment line
continue continue
line = line.strip() line = line.strip()
try: try:
lsplit = line.split(":") lsplit = line.split(':')
except Exception: except Exception:
continue continue
@ -63,13 +63,13 @@ class DelugeClient(object):
else: else:
continue continue
if username == "localclient": if username == 'localclient':
return username, password return username, password
return "", "" return '', ''
def _create_module_method(self, module, method): def _create_module_method(self, module, method):
fullname = "{0}.{1}".format(module, method) fullname = '{0}.{1}'.format(module, method)
def func(obj, *args, **kwargs): def func(obj, *args, **kwargs):
return self.remote_call(fullname, *args, **kwargs) return self.remote_call(fullname, *args, **kwargs)
@ -80,18 +80,18 @@ class DelugeClient(object):
def _introspect(self): def _introspect(self):
def splitter(value): def splitter(value):
return value.split(".") return value.split('.')
self.modules = [] self.modules = []
methods = self.remote_call("daemon.get_method_list").get() methods = self.remote_call('daemon.get_method_list').get()
methodmap = defaultdict(dict) methodmap = defaultdict(dict)
for module, method in imap(splitter, methods): for module, method in imap(splitter, methods):
methodmap[module][method] = self._create_module_method(module, method) methodmap[module][method] = self._create_module_method(module, method)
for module, methods in methodmap.items(): for module, methods in methodmap.items():
clsname = "DelugeModule{0}".format(module.capitalize()) clsname = 'DelugeModule{0}'.format(module.capitalize())
cls = type(clsname, (), methods) cls = type(clsname, (), methods)
setattr(self, module, cls()) setattr(self, module, cls())
self.modules.append(module) self.modules.append(module)
@ -133,7 +133,7 @@ class DelugeClient(object):
self._request_counter += 1 self._request_counter += 1
return response 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. """Connect to a daemon process.
:param host: str, the hostname of the daemon :param host: str, the hostname of the daemon
@ -145,11 +145,11 @@ class DelugeClient(object):
self.transfer.connect((host, port)) self.transfer.connect((host, port))
# Attempt to fetch local auth info if needed # 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() username, password = self._get_local_auth()
# Authenticate # Authenticate
self.remote_call("daemon.login", username, password).get() self.remote_call('daemon.login', username, password).get()
# Introspect available methods # Introspect available methods
self._introspect() self._introspect()

View file

@ -8,4 +8,4 @@ class DelugeRPCError(Exception):
self.traceback = traceback self.traceback = traceback
def __str__(self): 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)

View file

@ -6,7 +6,7 @@ import zlib
import rencode import rencode
__all__ = ["DelugeTransfer"] __all__ = ['DelugeTransfer']
class DelugeTransfer(object): class DelugeTransfer(object):
@ -33,7 +33,7 @@ class DelugeTransfer(object):
payload = zlib.compress(rencode.dumps(data)) payload = zlib.compress(rencode.dumps(data))
self.conn.sendall(payload) self.conn.sendall(payload)
buf = b"" buf = b''
while True: while True:
data = self.conn.recv(1024) data = self.conn.recv(1024)

View file

@ -94,8 +94,8 @@ class UTorrentClient(object):
def setprops(self, cur_hash, **kvpairs): def setprops(self, cur_hash, **kvpairs):
params = [('action', 'setprops'), ('hash', cur_hash)] params = [('action', 'setprops'), ('hash', cur_hash)]
for k, v in iteritems(kvpairs): for k, v in iteritems(kvpairs):
params.append(("s", k)) params.append(('s', k))
params.append(("v", v)) params.append(('v', v))
return self._action(params) return self._action(params)