Import needed modules and add redfams-generator
We will need a couple of modules to build the needed generator Also we will need a generator with redfams to work with Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=88 FS#88]
This commit is contained in:
@@ -26,8 +26,15 @@ Bot to mark pages which were/are subjects of redundance discussions
|
|||||||
with templates
|
with templates
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from pywikibot import pagegenerators
|
||||||
from pywikibot.bot import CurrentPageBot
|
from pywikibot.bot import CurrentPageBot
|
||||||
|
|
||||||
|
import jogobot
|
||||||
|
|
||||||
|
from lib.redfam import RedFamWorker
|
||||||
|
|
||||||
|
|
||||||
class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
||||||
"""
|
"""
|
||||||
@@ -47,8 +54,12 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
|||||||
@type iterable
|
@type iterable
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Copy needed args
|
# Init attribute
|
||||||
self.genFactory = genFactory
|
self.__redfams = None # Will hold a generator with our redfams
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|
||||||
# Build generator with genFactory
|
# Build generator with genFactory
|
||||||
self.build_generator()
|
self.build_generator()
|
||||||
@@ -56,6 +67,21 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
|||||||
# Run super class init with builded generator
|
# Run super class init with builded generator
|
||||||
super( MarkPagesBot, self ).__init__(generator=self.gen)
|
super( MarkPagesBot, self ).__init__(generator=self.gen)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def redfams(self):
|
||||||
|
"""
|
||||||
|
Holds redfams generator to work on in this bot
|
||||||
|
"""
|
||||||
|
# Create generator if not present
|
||||||
|
if not self.__redfams:
|
||||||
|
end_after = datetime.strptime(
|
||||||
|
jogobot.config["red.markpages"]["mark_done_after"],
|
||||||
|
"%Y-%m-%d" )
|
||||||
|
self.__redfams = RedFamWorker.gen_by_status_and_ending(
|
||||||
|
2, end_after)
|
||||||
|
|
||||||
|
return self.__redfams
|
||||||
|
|
||||||
def build_generator( self ):
|
def build_generator( self ):
|
||||||
"""
|
"""
|
||||||
Builds generator
|
Builds generator
|
||||||
|
|||||||
Reference in New Issue
Block a user