From 0ebf307bb80daa662a6f20add5fcb853d7de36f1 Mon Sep 17 00:00:00 2001 From: Jonathan Golder Date: Sat, 5 Nov 2016 19:32:02 +0100 Subject: [PATCH] Add markpages as subtask Markpages is a subtask of our Red-Bot Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=89 FS#89] # The following line will be added automatically # Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=88 FS#88] --- bots/markpages.py | 24 +++++++++++++++++++++--- jogobot | 2 +- lib/mysqlred.py | 2 +- red.py | 4 ++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/bots/markpages.py b/bots/markpages.py index 7548294..b7b45c0 100644 --- a/bots/markpages.py +++ b/bots/markpages.py @@ -69,6 +69,24 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() # Run super class init with builded generator super( MarkPagesBot, self ).__init__(generator=self.gen) + def run(self): + """ + Controls the overal parsing process, using super class for page switch + + Needed to do things before/after treating pages is done + """ + try: + + super( MarkPagesBot, self ).run() + + except: + raise + + else: + # Do status redfam status updates + for redfam in self.redfams: + redfam.update_status() + @property def redfams(self): """ @@ -79,8 +97,8 @@ 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 = RedFamWorker.gen_by_status_and_ending( - "archived", end_after) + self.__redfams = list( RedFamWorker.gen_by_status_and_ending( + "archived", end_after) ) return self.__redfams @@ -147,7 +165,7 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() # will return True if saved # False if not saved because of errors # None if change was not accepted by user - save_ret = self.put_current( self.new_text ) + save_ret = self.put_current( self.new_text, summary=summary ) # Status if add_ret is None or add_ret and save_ret: diff --git a/jogobot b/jogobot index 28d03f3..49ada29 160000 --- a/jogobot +++ b/jogobot @@ -1 +1 @@ -Subproject commit 28d03f35b848a33ad45d3f5f8f3f82e8c45534ec +Subproject commit 49ada2993e345600523c161c5e2516ec65625684 diff --git a/lib/mysqlred.py b/lib/mysqlred.py index 0bb843c..9e2e01b 100644 --- a/lib/mysqlred.py +++ b/lib/mysqlred.py @@ -308,7 +308,7 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );' type( self )._cached_insert_data.update( insert_data ) # Manualy construct self.data dict - data_keys = ( 'fam_hash', 'redpageid', 'beginning', 'ending', + data_keys = ( 'famhash', 'redpageid', 'beginning', 'ending', 'status', 'heading', 'article0', 'article1', 'article2', 'article3', 'article4', 'article5', 'article6', 'article7' ) diff --git a/red.py b/red.py index 733def2..81388d6 100644 --- a/red.py +++ b/red.py @@ -68,6 +68,10 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ): # Import related bot from bots.reddiscparser import DiscussionParserBot as Bot + elif subtask == "markpages": + # Import related bot + from bots.markpages import MarkPagesBot as Bot + # Subtask error else: jogobot.output( (