Building generators of config cats in sep Function
Since the main()-Function was too complex the logic to build generators out of categories provided in jogobot.conf was moved in a separate function [https://fs.golderweb.de/index.php?do=details&task_id=73 FS#73] Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=72 FS#72] Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=72 FS#72]
This commit is contained in:
@@ -106,7 +106,26 @@ class DiscussionParserBot(
|
|||||||
reddisc=red_page.page.title() ) )
|
reddisc=red_page.page.title() ) )
|
||||||
|
|
||||||
|
|
||||||
def main(*args): # noqa
|
def apply_conf_cat_generators( genFactory ):
|
||||||
|
"""
|
||||||
|
Builds generators for categories which are read from jogobot.config
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
@param genFactory: The GeneratorFactory to which the builded generators
|
||||||
|
should be added.
|
||||||
|
@type genFactory: pagegenerators.GeneratorFactory
|
||||||
|
"""
|
||||||
|
# Create Generators for configured Categories
|
||||||
|
for category in jogobot.config["redundances"]["redpage_cats"]:
|
||||||
|
cgen = genFactory.getCategoryGen(
|
||||||
|
category, gen_func=pagegenerators.CategorizedPageGenerator)
|
||||||
|
|
||||||
|
# If there is one, append to genFactory
|
||||||
|
if cgen:
|
||||||
|
genFactory.gens.append(cgen)
|
||||||
|
|
||||||
|
|
||||||
|
def main(*args):
|
||||||
"""
|
"""
|
||||||
Process command line arguments and invoke bot.
|
Process command line arguments and invoke bot.
|
||||||
|
|
||||||
@@ -168,16 +187,7 @@ def main(*args): # noqa
|
|||||||
# Check wether there are generators waiting for factoring, if not
|
# Check wether there are generators waiting for factoring, if not
|
||||||
# use configured categories
|
# use configured categories
|
||||||
if not genFactory.gens:
|
if not genFactory.gens:
|
||||||
|
apply_conf_cat_generators( genFactory )
|
||||||
# Create Generators for configured Categories
|
|
||||||
for category in jogobot.config["redundances"]["redpage_cats"]:
|
|
||||||
cgen = genFactory.getCategoryGen(
|
|
||||||
category,
|
|
||||||
gen_func=pagegenerators.CategorizedPageGenerator)
|
|
||||||
|
|
||||||
# If there is one, append to genFactory
|
|
||||||
if cgen:
|
|
||||||
genFactory.gens.append(cgen)
|
|
||||||
|
|
||||||
# Create combined Generator (Union of all Generators)
|
# Create combined Generator (Union of all Generators)
|
||||||
gen = genFactory.getCombinedGenerator()
|
gen = genFactory.getCombinedGenerator()
|
||||||
|
|||||||
Reference in New Issue
Block a user