Browse Source

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]
develop
Jonathan Golder 8 years ago
parent
commit
17bfb32ded
  1. 32
      reddiscparser.py

32
reddiscparser.py

@ -106,7 +106,26 @@ class DiscussionParserBot(
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.
@ -168,16 +187,7 @@ def main(*args): # noqa
# Check wether there are generators waiting for factoring, if not
# use configured categories
if not genFactory.gens:
# 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)
apply_conf_cat_generators( genFactory )
# Create combined Generator (Union of all Generators)
gen = genFactory.getCombinedGenerator()

Loading…
Cancel
Save