Browse Source

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]
develop
Jonathan Golder 8 years ago
parent
commit
870ed4bf25
  1. 4
      bots/markpages.py
  2. 15
      lib/redfam.py

4
bots/markpages.py

@ -107,7 +107,9 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
# We need the talkpage (and only this) of each existing page
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 ):
# Add reference to redfam to talkpages

15
lib/redfam.py

@ -633,7 +633,9 @@ 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 ):
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
in a generator
@ -647,11 +649,22 @@ class RedFamWorker( RedFam ):
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)
# 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
if filter_existing and not page.exists():
continue

Loading…
Cancel
Save