|
|
@ -515,45 +515,66 @@ class RedFamWorker( RedFam ): |
|
|
|
@type filter_redirects bool/None |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
# Helper to leave multidimensional loop |
|
|
|
# https://docs.python.org/3/faq/design.html#why-is-there-no-goto |
|
|
|
class Continue(Exception): |
|
|
|
pass |
|
|
|
|
|
|
|
class Break(Exception): |
|
|
|
pass |
|
|
|
|
|
|
|
# Iterate over articles in redfam |
|
|
|
for article in self.articlesList: |
|
|
|
# Not all list elements contain articles |
|
|
|
if not article: |
|
|
|
break |
|
|
|
|
|
|
|
page = pywikibot.Page(pywikibot.Link(article), pywikibot.Site()) |
|
|
|
# To be able to control outer loop from inside child loops |
|
|
|
try: |
|
|
|
|
|
|
|
# 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 |
|
|
|
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 |
|
|
|
# Not all list elements contain articles |
|
|
|
if not article: |
|
|
|
raise Break() |
|
|
|
|
|
|
|
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: |
|
|
|
raise Continue() |
|
|
|
# Filter non existing Pages if requested with |
|
|
|
# filter_existing=True |
|
|
|
else: |
|
|
|
self.article_add_status( "deleted", title=article ) |
|
|
|
if filter_existing: |
|
|
|
raise Continue() |
|
|
|
|
|
|
|
# Filter redirects if requested with filter_redirects=True |
|
|
|
if page.isRedirectPage(): |
|
|
|
self.article_add_status( "redirect", title=article ) |
|
|
|
if filter_redirects: |
|
|
|
raise Continue() |
|
|
|
# Filter noredirects if requested with filter_redirects=False |
|
|
|
else: |
|
|
|
self.article_remove_status("redirect", title=article ) |
|
|
|
if filter_redirects is False: |
|
|
|
raise Continue() |
|
|
|
|
|
|
|
# Exclude by article status |
|
|
|
for status in exclude_article_status: |
|
|
|
if self.article_has_status( status, title=article ): |
|
|
|
raise Continue() |
|
|
|
|
|
|
|
# Only include by article status |
|
|
|
for status in onlyinclude_article_status: |
|
|
|
if not self.article_has_status( status, title=article ): |
|
|
|
raise Continue() |
|
|
|
|
|
|
|
# Proxy loop control to outer loop |
|
|
|
except Continue: |
|
|
|
continue |
|
|
|
except Break: |
|
|
|
break |
|
|
|
|
|
|
|
# Yield filtered pages |
|
|
|
yield page |
|
|
|