summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-17 01:07:33 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-17 01:07:33 +0200
commit730b160e28d711fad96e6a61070e374ad0966566 (patch)
treefe3f8cf4161de8f93cddf29ea49464b493083e2b
parentSpare code cosmetics (1) (diff)
downloadpyload-730b160e28d711fad96e6a61070e374ad0966566.tar.xz
Spare code cosmetics (2)
-rw-r--r--docs/build_docs.py8
-rw-r--r--pyload/manager/Remote.py8
-rw-r--r--pyload/remote/SocketBackend.py7
-rw-r--r--pyload/remote/thriftbackend/Processor.py3
-rw-r--r--pyload/remote/thriftbackend/Protocol.py4
-rw-r--r--pyload/remote/thriftbackend/thriftgen/pyload/constants.py1
-rw-r--r--pyload/utils/pylgettext.py12
-rw-r--r--pyload/webui/middlewares.py18
8 files changed, 31 insertions, 30 deletions
diff --git a/docs/build_docs.py b/docs/build_docs.py
index 15fc2070d..8a7ab7a18 100644
--- a/docs/build_docs.py
+++ b/docs/build_docs.py
@@ -34,7 +34,9 @@ sys.path.append(dir_name)
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest',
+ 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
+ 'sphinx.ext.viewcode']
autosummary_generate = True
autodoc_default_flags = ['members']
@@ -201,8 +203,8 @@ htmlhelp_basename = 'pyLoaddoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'pyLoad.tex', u'pyLoad Documentation',
- u'pyLoad Team', 'manual'),
+ ('index', 'pyLoad.tex', u'pyLoad Documentation',
+ u'pyLoad Team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py
index a27667070..b18035a00 100644
--- a/pyload/manager/Remote.py
+++ b/pyload/manager/Remote.py
@@ -4,6 +4,7 @@
from threading import Thread
from traceback import print_exc
+
class BackendBase(Thread):
def __init__(self, manager):
@@ -43,7 +44,7 @@ class BackendBase(Thread):
def stop(self):
- self.enabled = False# set flag and call shutdowm message, so thread can react
+ self.enabled = False #: set flag and call shutdowm message, so thread can react
self.shutdown()
@@ -57,9 +58,8 @@ class RemoteManager(object):
if self.core.remote:
self.available.append("ThriftBackend")
-# else:
-# self.available.append("SocketBackend")
-
+ # else:
+ # self.available.append("SocketBackend")
def startBackends(self):
host = self.core.config.get("remote", "listenaddr")
diff --git a/pyload/remote/SocketBackend.py b/pyload/remote/SocketBackend.py
index 6b88663f8..05b2d8425 100644
--- a/pyload/remote/SocketBackend.py
+++ b/pyload/remote/SocketBackend.py
@@ -4,22 +4,19 @@ import SocketServer
from pyload.manager.Remote import BackendBase
-class RequestHandler(SocketServer.BaseRequestHandler):
+class RequestHandler(SocketServer.BaseRequestHandler):
def setup(self):
pass
def handle(self):
-
print self.request.recv(1024)
-
class SocketBackend(BackendBase):
-
def setup(self, host, port):
- #local only
+ # local only
self.server = SocketServer.ThreadingTCPServer(("localhost", port), RequestHandler)
diff --git a/pyload/remote/thriftbackend/Processor.py b/pyload/remote/thriftbackend/Processor.py
index 24a0c05b6..7ccc2bee2 100644
--- a/pyload/remote/thriftbackend/Processor.py
+++ b/pyload/remote/thriftbackend/Processor.py
@@ -2,6 +2,7 @@
from pyload.remote.thriftbackend.thriftgen.pyload import Pyload
+
class Processor(Pyload.Processor):
def __init__(self, *args, **kwargs):
@@ -66,7 +67,7 @@ class Processor(Pyload.Processor):
self._processMap[name](self, seqid, iprot, oprot)
else:
- #no permission
+ # no permission
iprot.skip(Pyload.TType.STRUCT)
iprot.readMessageEnd()
# 21 - Not authorized
diff --git a/pyload/remote/thriftbackend/Protocol.py b/pyload/remote/thriftbackend/Protocol.py
index c020e7a23..cc5352d40 100644
--- a/pyload/remote/thriftbackend/Protocol.py
+++ b/pyload/remote/thriftbackend/Protocol.py
@@ -2,12 +2,13 @@
from thrift.protocol import TBinaryProtocol
+
class Protocol(TBinaryProtocol.TBinaryProtocol):
def writeString(self, str):
try:
str = str.encode("utf8", "ignore")
- except Exception, e:
+ except Exception:
pass
self.writeI32(len(str))
@@ -26,7 +27,6 @@ class Protocol(TBinaryProtocol.TBinaryProtocol):
class ProtocolFactory(TBinaryProtocol.TBinaryProtocolFactory):
-
def getProtocol(self, trans):
prot = Protocol(trans, self.strictRead, self.strictWrite)
return prot
diff --git a/pyload/remote/thriftbackend/thriftgen/pyload/constants.py b/pyload/remote/thriftbackend/thriftgen/pyload/constants.py
index 3bdd64cc1..e0a811c8a 100644
--- a/pyload/remote/thriftbackend/thriftgen/pyload/constants.py
+++ b/pyload/remote/thriftbackend/thriftgen/pyload/constants.py
@@ -8,3 +8,4 @@
from thrift.Thrift import TType, TMessageType, TException
from ttypes import *
+
diff --git a/pyload/utils/pylgettext.py b/pyload/utils/pylgettext.py
index 0e3ebad80..1f31cf42d 100644
--- a/pyload/utils/pylgettext.py
+++ b/pyload/utils/pylgettext.py
@@ -6,12 +6,10 @@ _searchdirs = None
origfind = find
+
def setpaths(pathlist):
global _searchdirs
- if isinstance(pathlist, list):
- _searchdirs = pathlist
- else:
- _searchdirs = list(pathlist)
+ _searchdirs = pathlist if isinstance(pathlist, list) else list(pathlist)
def addpath(path):
@@ -32,8 +30,7 @@ def delpath(path):
def clearpath():
global _searchdirs
- if _searchdirs is not None:
- _searchdirs = None
+ _searchdirs = None
def find(domain, localedir=None, languages=None, all=False):
@@ -51,8 +48,7 @@ def find(domain, localedir=None, languages=None, all=False):
results = filter(lambda x: x is not None, results)
if len(results) == 0:
return None
- else:
- return results[0]
+ return results[0]
else:
return results
diff --git a/pyload/webui/middlewares.py b/pyload/webui/middlewares.py
index 26537f900..f6a2d8a32 100644
--- a/pyload/webui/middlewares.py
+++ b/pyload/webui/middlewares.py
@@ -7,6 +7,7 @@ try:
except ImportError:
from StringIO import StringIO
+
class StripPathMiddleware(object):
def __init__(self, app):
@@ -40,6 +41,7 @@ class PrefixMiddleware(object):
# WSGI middleware
# Gzip-encodes the response.
+
class GZipMiddleWare(object):
def __init__(self, application, compress_level=6):
@@ -60,21 +62,25 @@ class GZipMiddleWare(object):
return response.write()
+
def header_value(headers, key):
for header, value in headers:
if key.lower() == header.lower():
return value
+
def update_header(headers, key, value):
remove_header(headers, key)
headers.append((key, value))
+
def remove_header(headers, key):
for header, value in headers:
if key.lower() == header.lower():
headers.remove((header, value))
break
+
class GzipResponse(object):
def __init__(self, start_response, compress_level):
@@ -88,16 +94,15 @@ class GzipResponse(object):
def gzip_start_response(self, status, headers, exc_info=None):
self.headers = headers
- ct = header_value(headers,'content-type')
- ce = header_value(headers,'content-encoding')
+ ct = header_value(headers, 'content-type')
+ ce = header_value(headers, 'content-encoding')
cl = header_value(headers, 'content-length')
if cl:
cl = int(cl)
else:
cl = 201
self.compressible = False
- if ct and (ct.startswith('text/') or ct.startswith('application/')) \
- and 'zip' not in ct and cl > 200:
+ if ct and (ct.startswith('text/') or ct.startswith('application/')) and 'zip' not in ct and cl > 200:
self.compressible = True
if ce:
self.compressible = False
@@ -119,8 +124,7 @@ class GzipResponse(object):
def finish_response(self, app_iter):
if self.compressible:
- output = gzip.GzipFile(mode='wb', compresslevel=self.compress_level,
- fileobj=self.buffer)
+ output = gzip.GzipFile(mode='wb', compresslevel=self.compress_level, fileobj=self.buffer)
else:
output = self.buffer
try:
@@ -136,5 +140,5 @@ class GzipResponse(object):
pass
content_length = self.buffer.tell()
- update_header(self.headers, "Content-Length" , str(content_length))
+ update_header(self.headers, "Content-Length", str(content_length))
self.start_response(self.status, self.headers)