mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
Reformat python code to be compliant with PEP8
The following command is used: `pycodestyle --ignore=E265,E722 --max-line-length=100 <py files>`
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#VERSION: 1.41
|
||||
#VERSION: 1.42
|
||||
|
||||
# Author:
|
||||
# Fabien Devaux <fab AT gnux DOT info>
|
||||
@@ -56,6 +56,7 @@ CATEGORIES = {'all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pic
|
||||
# As a convention, try to list results by decreasing number of seeds or similar
|
||||
################################################################################
|
||||
|
||||
|
||||
def initialize_engines():
|
||||
""" Import available engines
|
||||
|
||||
@@ -69,11 +70,11 @@ def initialize_engines():
|
||||
if len(engi) == 0 or engi.startswith('_'):
|
||||
continue
|
||||
try:
|
||||
#import engines.[engine]
|
||||
# import engines.[engine]
|
||||
engine_module = __import__(".".join(("engines", engi)))
|
||||
#get low-level module
|
||||
# get low-level module
|
||||
engine_module = getattr(engine_module, engi)
|
||||
#bind class name
|
||||
# bind class name
|
||||
globals()[engi] = getattr(engine_module, engi)
|
||||
supported_engines.append(engi)
|
||||
except:
|
||||
@@ -81,6 +82,7 @@ def initialize_engines():
|
||||
|
||||
return supported_engines
|
||||
|
||||
|
||||
def engines_to_xml(supported_engines):
|
||||
""" Generates xml for supported engines """
|
||||
tab = " " * 4
|
||||
@@ -90,14 +92,16 @@ def engines_to_xml(supported_engines):
|
||||
|
||||
supported_categories = ""
|
||||
if hasattr(search_engine, "supported_categories"):
|
||||
supported_categories = " ".join((key for key in search_engine.supported_categories.keys()
|
||||
supported_categories = " ".join((key
|
||||
for key in search_engine.supported_categories.keys()
|
||||
if key is not "all"))
|
||||
|
||||
yield "".join((tab, "<", short_name, ">\n",
|
||||
tab, tab, "<name>", search_engine.name, "</name>\n",
|
||||
tab, tab, "<url>", search_engine.url, "</url>\n",
|
||||
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
||||
tab, "</", short_name, ">\n"))
|
||||
yield "".join((tab, "<", short_name, ">\n",
|
||||
tab, tab, "<name>", search_engine.name, "</name>\n",
|
||||
tab, tab, "<url>", search_engine.url, "</url>\n",
|
||||
tab, tab, "<categories>", supported_categories, "</categories>\n",
|
||||
tab, "</", short_name, ">\n"))
|
||||
|
||||
|
||||
def displayCapabilities(supported_engines):
|
||||
"""
|
||||
@@ -115,6 +119,7 @@ def displayCapabilities(supported_engines):
|
||||
"</capabilities>"))
|
||||
print(xml)
|
||||
|
||||
|
||||
def run_search(engine_list):
|
||||
""" Run search in engine
|
||||
|
||||
@@ -126,7 +131,7 @@ def run_search(engine_list):
|
||||
engine, what, cat = engine_list
|
||||
try:
|
||||
engine = engine()
|
||||
#avoid exceptions due to invalid category
|
||||
# avoid exceptions due to invalid category
|
||||
if hasattr(engine, 'supported_categories'):
|
||||
if cat in engine.supported_categories:
|
||||
engine.search(what, cat)
|
||||
@@ -136,6 +141,7 @@ def run_search(engine_list):
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def main(args):
|
||||
fix_encoding()
|
||||
supported_engines = initialize_engines()
|
||||
@@ -152,18 +158,18 @@ def main(args):
|
||||
raise SystemExit("./nova2.py [all|engine1[,engine2]*] <category> <keywords>\n"
|
||||
"available engines: %s" % (','.join(supported_engines)))
|
||||
|
||||
#get only unique engines with set
|
||||
# get only unique engines with set
|
||||
engines_list = set(e.lower() for e in args[0].strip().split(','))
|
||||
|
||||
if 'all' in engines_list:
|
||||
engines_list = supported_engines
|
||||
else:
|
||||
#discard un-supported engines
|
||||
# discard un-supported engines
|
||||
engines_list = [engine for engine in engines_list
|
||||
if engine in supported_engines]
|
||||
|
||||
if not engines_list:
|
||||
#engine list is empty. Nothing to do here
|
||||
# engine list is empty. Nothing to do here
|
||||
return
|
||||
|
||||
cat = args[1].lower()
|
||||
@@ -174,11 +180,12 @@ def main(args):
|
||||
what = urllib.quote(' '.join(args[2:]))
|
||||
|
||||
if THREADED:
|
||||
#child process spawning is controlled min(number of searches, number of cpu)
|
||||
# child process spawning is controlled min(number of searches, number of cpu)
|
||||
pool = Pool(min(len(engines_list), MAX_THREADS))
|
||||
pool.map(run_search, ([globals()[engine], what, cat] for engine in engines_list))
|
||||
else:
|
||||
map(run_search, ([globals()[engine], what, cat] for engine in engines_list))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(argv[1:])
|
||||
|
||||
Reference in New Issue
Block a user