Merge branch 'fs#146-famhash-generator' into develop
This commit is contained in:
@@ -62,6 +62,9 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
|||||||
# Init attribute
|
# Init attribute
|
||||||
self.__redfams = None # Will hold a generator with our redfams
|
self.__redfams = None # Will hold a generator with our redfams
|
||||||
|
|
||||||
|
if "famhash" in kwargs:
|
||||||
|
self.famhash = kwargs["famhash"]
|
||||||
|
|
||||||
# We do not use predefined genFactory as there is no sensefull case to
|
# We do not use predefined genFactory as there is no sensefull case to
|
||||||
# give a generator via cmd-line for this right now
|
# give a generator via cmd-line for this right now
|
||||||
self.genFactory = pagegenerators.GeneratorFactory()
|
self.genFactory = pagegenerators.GeneratorFactory()
|
||||||
@@ -102,6 +105,13 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
|||||||
end_after = datetime.strptime(
|
end_after = datetime.strptime(
|
||||||
jogobot.config["red.markpages"]["mark_done_after"],
|
jogobot.config["red.markpages"]["mark_done_after"],
|
||||||
"%Y-%m-%d" )
|
"%Y-%m-%d" )
|
||||||
|
|
||||||
|
if hasattr(self, "famhash"):
|
||||||
|
self.__redfams = list(
|
||||||
|
RedFamWorker.session.query(RedFamWorker).filter(
|
||||||
|
RedFamWorker.famhash == self.famhash ) )
|
||||||
|
|
||||||
|
else:
|
||||||
self.__redfams = list( RedFamWorker.gen_by_status_and_ending(
|
self.__redfams = list( RedFamWorker.gen_by_status_and_ending(
|
||||||
"archived", end_after) )
|
"archived", end_after) )
|
||||||
|
|
||||||
|
|||||||
23
red.py
23
red.py
@@ -60,7 +60,7 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ):
|
|||||||
@rtype tuple
|
@rtype tuple
|
||||||
"""
|
"""
|
||||||
# kwargs are passed to selected bot as **kwargs
|
# kwargs are passed to selected bot as **kwargs
|
||||||
kwargs = dict()
|
kwargs = subtask_args
|
||||||
|
|
||||||
if not subtask or subtask == "discparser":
|
if not subtask or subtask == "discparser":
|
||||||
# Default case: discparser
|
# Default case: discparser
|
||||||
@@ -83,6 +83,25 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ):
|
|||||||
return ( subtask, Bot, genFactory, kwargs )
|
return ( subtask, Bot, genFactory, kwargs )
|
||||||
|
|
||||||
|
|
||||||
|
def parse_red_args( argkey, value ):
|
||||||
|
"""
|
||||||
|
Process additional args for red.py
|
||||||
|
|
||||||
|
@param argkey The arguments key
|
||||||
|
@type argkey str
|
||||||
|
@param value The arguments value
|
||||||
|
@type value str
|
||||||
|
|
||||||
|
@return Tuple with (key, value) if given pair is relevant, else None
|
||||||
|
@rtype tuple or None
|
||||||
|
"""
|
||||||
|
|
||||||
|
if argkey.startswith("-famhash"):
|
||||||
|
return ( "famhash", value )
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def main(*args):
|
def main(*args):
|
||||||
"""
|
"""
|
||||||
Process command line arguments and invoke bot.
|
Process command line arguments and invoke bot.
|
||||||
@@ -110,7 +129,7 @@ def main(*args):
|
|||||||
|
|
||||||
# Parse local Args to get information about subtask
|
# Parse local Args to get information about subtask
|
||||||
( subtask, genFactory, subtask_args ) = jogobot.bot.parse_local_args(
|
( subtask, genFactory, subtask_args ) = jogobot.bot.parse_local_args(
|
||||||
local_args )
|
local_args, parse_red_args )
|
||||||
|
|
||||||
# select subtask and prepare args
|
# select subtask and prepare args
|
||||||
( subtask, Bot, genFactory, kwargs ) = prepare_bot(
|
( subtask, Bot, genFactory, kwargs ) = prepare_bot(
|
||||||
|
|||||||
Reference in New Issue
Block a user