Change redfam generator filters
Change and clear up the filters in redfam generator to keep track of article status and use positive conditionals
This commit is contained in:
@@ -491,6 +491,28 @@ class RedFamWorker( RedFam ):
|
|||||||
|
|
||||||
page = pywikibot.Page(pywikibot.Link(article), pywikibot.Site())
|
page = pywikibot.Page(pywikibot.Link(article), pywikibot.Site())
|
||||||
|
|
||||||
|
# Filter existing pages if requested with filter_existing=False
|
||||||
|
if page.exists():
|
||||||
|
self.article_remove_status( "deleted", title=article )
|
||||||
|
if filter_existing is False:
|
||||||
|
continue
|
||||||
|
# Filter non existing Pages if requested with filter_existing=True
|
||||||
|
else:
|
||||||
|
self.article_add_status( "deleted", title=article )
|
||||||
|
if filter_existing:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Filter redirects if requested with filter_redirects=True
|
||||||
|
if page.isRedirectPage():
|
||||||
|
self.article_add_status( "redirect", title=article )
|
||||||
|
if filter_redirects:
|
||||||
|
continue
|
||||||
|
# Filter noredirects if requested with filter_redirects=False
|
||||||
|
else:
|
||||||
|
self.article_remove_status("redirect", title=article )
|
||||||
|
if filter_redirects is False:
|
||||||
|
continue
|
||||||
|
|
||||||
# Exclude by article status
|
# Exclude by article status
|
||||||
for status in exclude_article_status:
|
for status in exclude_article_status:
|
||||||
if self.article_has_status( status, title=article ):
|
if self.article_has_status( status, title=article ):
|
||||||
@@ -501,20 +523,6 @@ class RedFamWorker( RedFam ):
|
|||||||
if not self.article_has_status( status, title=article ):
|
if not self.article_has_status( status, title=article ):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 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 filtered pages
|
||||||
yield page
|
yield page
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user