Add methods to build gen to DiscussionParser
With the new wrapper script the Bot gets a GenFactory and has to build a generator out of it by its own Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=83 FS#83]
This commit is contained in:
@@ -58,7 +58,47 @@ class DiscussionParserBot(
|
|||||||
to work.
|
to work.
|
||||||
@type generator: generator.
|
@type generator: generator.
|
||||||
"""
|
"""
|
||||||
super( DiscussionParserBot, self ).__init__(generator=generator)
|
|
||||||
|
def build_generator(self):
|
||||||
|
"""
|
||||||
|
Builds generator to work on, based on self.genFactory
|
||||||
|
"""
|
||||||
|
# Check wether there are generators waiting for factoring, if not
|
||||||
|
# use configured categories
|
||||||
|
if not self.genFactory.gens:
|
||||||
|
self.apply_conf_cat_generators()
|
||||||
|
|
||||||
|
# Create combined Generator (Union of all Generators)
|
||||||
|
gen = self.genFactory.getCombinedGenerator()
|
||||||
|
|
||||||
|
if gen:
|
||||||
|
# The preloading generator is responsible for downloading multiple
|
||||||
|
# pages from the wiki simultaneously.
|
||||||
|
self.gen = pagegenerators.PreloadingGenerator(gen)
|
||||||
|
|
||||||
|
else:
|
||||||
|
pywikibot.showHelp()
|
||||||
|
|
||||||
|
def apply_conf_cat_generators( self ):
|
||||||
|
"""
|
||||||
|
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"]:
|
||||||
|
gen = self.genFactory.getCategoryGen(
|
||||||
|
category, gen_func=pagegenerators.CategorizedPageGenerator)
|
||||||
|
|
||||||
|
# If there is one, append to genFactory
|
||||||
|
if gen:
|
||||||
|
self.genFactory.gens.append(gen)
|
||||||
|
|
||||||
|
# Reset gen for next iteration
|
||||||
|
gen = None
|
||||||
|
|
||||||
def run( self ):
|
def run( self ):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user