Update redfam.article_generator use article status
To be able to filter articles by status of that article Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=89 FS#89]
This commit is contained in:
@@ -107,7 +107,9 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
|
|||||||
|
|
||||||
# We need the talkpage (and only this) of each existing page
|
# We need the talkpage (and only this) of each existing page
|
||||||
for talkpage in pagegenerators.PageWithTalkPageGenerator(
|
for talkpage in pagegenerators.PageWithTalkPageGenerator(
|
||||||
redfam.article_generator( filter_existing=True ),
|
redfam.article_generator(
|
||||||
|
filter_existing=True,
|
||||||
|
exclude_article_status=["marked"] ),
|
||||||
return_talk_only=True ):
|
return_talk_only=True ):
|
||||||
|
|
||||||
# Add reference to redfam to talkpages
|
# Add reference to redfam to talkpages
|
||||||
|
|||||||
@@ -633,7 +633,9 @@ class RedFamWorker( RedFam ):
|
|||||||
# with wrong month abreviations in strptime
|
# with wrong month abreviations in strptime
|
||||||
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
||||||
|
|
||||||
def article_generator(self, filter_existing=None, filter_redirects=None ):
|
def article_generator(self, filter_existing=None, filter_redirects=None,
|
||||||
|
exclude_article_status=[],
|
||||||
|
onlyinclude_article_status=[] ):
|
||||||
"""
|
"""
|
||||||
Yields pywikibot pageobjects for articles belonging to this redfams
|
Yields pywikibot pageobjects for articles belonging to this redfams
|
||||||
in a generator
|
in a generator
|
||||||
@@ -647,11 +649,22 @@ class RedFamWorker( RedFam ):
|
|||||||
set to False to get only redirectpages,
|
set to False to get only redirectpages,
|
||||||
unset/None results in not filtering
|
unset/None results in not filtering
|
||||||
@type filter_redirects bool/None
|
@type filter_redirects bool/None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Iterate over articles in redfam
|
# Iterate over articles in redfam
|
||||||
for article in self._articlesList:
|
for article in self._articlesList:
|
||||||
page = pywikibot.Page(pywikibot.Link(article), self.site)
|
page = pywikibot.Page(pywikibot.Link(article), self.site)
|
||||||
|
|
||||||
|
# Exclude by article status
|
||||||
|
for status in exclude_article_status:
|
||||||
|
if self.article_has_status( status, title=article ):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Only include by article status
|
||||||
|
for status in onlyinclude_article_status:
|
||||||
|
if not self.article_has_status( status, title=article ):
|
||||||
|
continue
|
||||||
|
|
||||||
# Filter non existing Pages if requested with filter_existing=True
|
# Filter non existing Pages if requested with filter_existing=True
|
||||||
if filter_existing and not page.exists():
|
if filter_existing and not page.exists():
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user