Merge branch 'fs#87-redfam-article-generator' into fs#25-mark-done
This commit is contained in:
@@ -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,42 @@ class RedFamWorker( RedFam ):
|
||||
# with wrong month abreviations in strptime
|
||||
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
||||
|
||||
def article_generator(self, filter_existing=None, filter_redirects=None ):
|
||||
"""
|
||||
Yields pywikibot pageobjects for articles belonging to this redfams
|
||||
in a generator
|
||||
self.
|
||||
|
||||
@param filter_existing Set to True to only get existing pages
|
||||
set to False to only get nonexisting pages
|
||||
unset/None results in not filtering
|
||||
@type filter_existing bool/None
|
||||
@param filter_redirects Set to True to get only noredirectpages,
|
||||
set to False to get only redirectpages,
|
||||
unset/None results in not filtering
|
||||
@type filter_redirects bool/None
|
||||
"""
|
||||
# Iterate over articles in redfam
|
||||
for article in self._articlesList:
|
||||
page = pywikibot.Page(pywikibot.Link(article), self.site)
|
||||
|
||||
# Filter non existing Pages if requested with filter_existing=True
|
||||
if filter_existing and not page.exists():
|
||||
continue
|
||||
# Filter existing pages if requested with filter_existing=False
|
||||
elif filter_existing is False and page.exists():
|
||||
continue
|
||||
|
||||
# Filter redirects if requested with filter_redirects=True
|
||||
if filter_redirects and page.isRedirectPage():
|
||||
continue
|
||||
# Filter noredirects if requested with filter_redirects=False
|
||||
elif filter_redirects is False and not page.isRedirectPage():
|
||||
continue
|
||||
|
||||
# Yield filtered pages
|
||||
yield page
|
||||
|
||||
def update_status( self ):
|
||||
"""
|
||||
Sets status to 3 when worked on
|
||||
|
||||
Reference in New Issue
Block a user