From efa919ff2739ae8093a42bc160628bfdab07d7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sun, 28 Aug 2016 16:39:32 +0200 Subject: [PATCH] Add new bot with basic structure We need a bot to work on pages which are subjects of redfams and on the belonging talk page Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=88 FS#88] --- bots/markpages.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 bots/markpages.py diff --git a/bots/markpages.py b/bots/markpages.py new file mode 100644 index 0000000..6bdcb5a --- /dev/null +++ b/bots/markpages.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# markpages.py +# +# Copyright 2016 GOLDERWEB – Jonathan Golder +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +""" +Bot to mark pages which were/are subjects of redundance discussions +with templates +""" + +from pywikibot.bot import CurrentPageBot + + +class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() + """ + Bot class to mark pages which were/are subjects of redundance discussions + with templates + """ + + def __init__( self, genFactory, **kwargs ): + """ + Constructor + + Parameters: + @param genFactory GenFactory with parsed pagegenerator args to + build generator + @type genFactory pagegenerators.GeneratorFactory + @param **kwargs Additional args + @type iterable + """ + + # Copy needed args + self.genFactory = genFactory + + # Build generator with genFactory + self.build_generator() + + # Run super class init with builded generator + super( MarkPagesBot, self ).__init__(generator=self.gen) + + def build_generator( self ): + """ + Builds generator + """ + self.gen = self.genFactory.getCombinedGenerator() + + def treat_page( self ): + """ + Handles work on current page + """ + + # Here is the place where to do what ever you want + print( self.current_page.title() )