jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668107 )
Change subject: [IMPR] simplify code in treat_disamb_only ......................................................................
[IMPR] simplify code in treat_disamb_only
- move code out of try statement in treat_disamb_only - remove include = False statement; include is False by default
Change-Id: I2c4946299df5ed8ad2e5befdb080eb4897e11e36 --- M scripts/solve_disambiguation.py 1 file changed, 12 insertions(+), 12 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index b8bc74d..65d6edc 100755 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -747,13 +747,6 @@ new_targets = [] try: text = ref_page.get() - ignore_reason = self.checkContents(text) - if ignore_reason: - pywikibot.output( - '\n\nSkipping {0} because it contains {1}.\n\n' - .format(ref_page.title(), ignore_reason)) - else: - include = True except pywikibot.IsRedirectPage: pywikibot.output('{0} is a redirect to {1}' .format(ref_page.title(), disamb_page.title())) @@ -792,8 +785,16 @@ pywikibot.output( 'Page [[{0}]] does not seem to exist?! Skipping.' .format(ref_page.title())) - include = False - if include in (True, 'redirect'): + else: + ignore_reason = self.checkContents(text) + if ignore_reason: + pywikibot.output( + '\n\nSkipping {0} because it contains {1}.\n\n' + .format(ref_page.title(), ignore_reason)) + else: + include = True + + if include: # save the original text so we can show the changes later original_text = text n = 0 @@ -817,9 +818,8 @@ foundlink = pywikibot.Link(m.group('title'), disamb_page.site) foundlink.parse() - except pywikibot.Error: - continue - except ValueError: # T111513 + except (pywikibot.Error, + ValueError): # T111513 continue
# ignore interwiki links