From e5989305a4a2fe44f4e17d7548fad5fbcdbf8421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sun, 28 Aug 2016 13:20:13 +0200 Subject: [PATCH] Add a generator to redfam yielding article pages To work on articles of a redfam a generator which yields belonging articles is necessary Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=87 FS#87] --- lib/redfam.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/redfam.py b/lib/redfam.py index b2277fc..284b54e 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -57,6 +57,9 @@ class RedFam: @param heading str Original heading of RedFam (Link) """ + # Having pywikibot.Site() is a good idea most of the time + self.site = pywikibot.Site() + # Database interface self._mysql = MysqlRedFam( fam_hash ) @@ -455,6 +458,15 @@ class RedFamWorker( RedFam ): # with wrong month abreviations in strptime locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') + def article_generator(self): + """ + Yields pywikibot pageobjects for articles belonging to this redfams + in a generator + self. + """ + for article in self._articlesList: + yield pywikibot.Page(pywikibot.Link(article), self.site) + def update_status( self ): """ Sets status to 3 when worked on