jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634696 )
Change subject: [IMPR] Decrease nested flow statements in wikimedia_sites.py ......................................................................
[IMPR] Decrease nested flow statements in wikimedia_sites.py
Change-Id: I5a40aaff99e46782d26cae4e5ed2bb5a3f7e26d4 --- M scripts/maintenance/wikimedia_sites.py 1 file changed, 22 insertions(+), 23 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py index 6a352ee..0ccc6c0 100755 --- a/scripts/maintenance/wikimedia_sites.py +++ b/scripts/maintenance/wikimedia_sites.py @@ -58,8 +58,8 @@ # put the missing languages to the right place missing = original != new and set(original) - set(new) if missing: - pywikibot.warning("['%s'] not listed at wikistats." - % "', '".join(missing)) + pywikibot.warning("['{}'] not listed at wikistats." + .format("', '".join(missing))) index = {} for code in missing: index[original.index(code)] = code @@ -70,27 +70,26 @@
if original == new: pywikibot.output('The lists match!') - else: - pywikibot.output("The lists don't match, the new list is:") - text = ' languages_by_size = [\n' - line = ' ' * 7 - for code in new: - if len(line) + len(code) < 76: - line += " '%s'," % code - else: - text += '%s\n' % line - line = ' ' * 7 - line += " '%s'," % code - text += '%s\n' % line - text += ' ]' - pywikibot.output(text) - family_file_name = 'pywikibot/families/%s_family.py' % family - with codecs.open(family_file_name, 'r', 'utf8') as family_file: - family_text = family_file.read() - family_text = re.sub(r'(?msu)^ {4}languages_by_size.+?]', - text, family_text, 1) - with codecs.open(family_file_name, 'w', 'utf8') as family_file: - family_file.write(family_text) + return + + pywikibot.output("The lists don't match, the new list is:") + text = ' languages_by_size = [\n' + line = ' ' * 7 + for code in new: + if len(line) + len(code) >= 76: + text += line + '\n' + line = ' ' * 7 + line += " '{}',".format(code) + text += line + '\n' + text += ' ]' + pywikibot.output(text) + family_file_name = 'pywikibot/families/%s_family.py' % family + with codecs.open(family_file_name, 'r', 'utf8') as family_file: + family_text = family_file.read() + family_text = re.sub(r'(?msu)^ {4}languages_by_size.+?]', + text, family_text, 1) + with codecs.open(family_file_name, 'w', 'utf8') as family_file: + family_file.write(family_text)
if __name__ == '__main__':
pywikibot-commits@lists.wikimedia.org