diff --git a/bots/markpages.py b/bots/markpages.py index 971e9c2..d2e8d7f 100644 --- a/bots/markpages.py +++ b/bots/markpages.py @@ -62,6 +62,9 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() # Init attribute 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 # give a generator via cmd-line for this right now self.genFactory = pagegenerators.GeneratorFactory() @@ -102,8 +105,15 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() end_after = datetime.strptime( jogobot.config["red.markpages"]["mark_done_after"], "%Y-%m-%d" ) - self.__redfams = list( RedFamWorker.gen_by_status_and_ending( - "archived", end_after) ) + + 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( + "archived", end_after) ) return self.__redfams diff --git a/red.py b/red.py index f4be812..8ea4f7b 100644 --- a/red.py +++ b/red.py @@ -60,7 +60,7 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ): @rtype tuple """ # kwargs are passed to selected bot as **kwargs - kwargs = dict() + kwargs = subtask_args if not subtask or subtask == "discparser": # Default case: discparser @@ -83,6 +83,25 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ): 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): """ Process command line arguments and invoke bot. @@ -110,7 +129,7 @@ def main(*args): # Parse local Args to get information about subtask ( subtask, genFactory, subtask_args ) = jogobot.bot.parse_local_args( - local_args ) + local_args, parse_red_args ) # select subtask and prepare args ( subtask, Bot, genFactory, kwargs ) = prepare_bot(