jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/558554 )

Change subject: [IMPR] Avoid deeply nested flow statements
......................................................................

[IMPR] Avoid deeply nested flow statements

Change-Id: Ibb76b359b86420741f432d3d22fc12d08854a26b
---
M scripts/nowcommons.py
1 file changed, 25 insertions(+), 23 deletions(-)

Approvals:
  Dvorapa: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index 1940081..7dc4073 100755
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -234,31 +234,33 @@
     def findFilenameOnCommons(self, localImagePage):
         """Find filename on Commons."""
         for templateName, params in localImagePage.templatesWithParams():
-            if templateName in self.nc_templates:
-                if params == []:
+            if templateName not in self.nc_templates:
+                continue
+
+            if not params:
+                filenameOnCommons = localImagePage.title(with_ns=False)
+            elif self.site.lang in namespaceInTemplate:
+                skip = False
+                filenameOnCommons = None
+                for par in params:
+                    val = par.split('=')
+                    if len(val) == 1 and not skip:
+                        filenameOnCommons = par[par.index(':') + 1:]
+                        break
+                    if val[0].strip() == '1':
+                        filenameOnCommons = \
+                            val[1].strip()[val[1].strip().index(':') + 1:]
+                        break
+                    skip = True
+                if not filenameOnCommons:
                     filenameOnCommons = localImagePage.title(with_ns=False)
-                elif self.site.lang in namespaceInTemplate:
-                    skip = False
-                    filenameOnCommons = None
-                    for par in params:
-                        val = par.split('=')
-                        if len(val) == 1 and not skip:
-                            filenameOnCommons = par[par.index(':') + 1:]
-                            break
-                        if val[0].strip() == '1':
-                            filenameOnCommons = \
-                                val[1].strip()[val[1].strip().index(':') + 1:]
-                            break
-                        skip = True
-                    if not filenameOnCommons:
-                        filenameOnCommons = localImagePage.title(with_ns=False)
+            else:
+                val = params[0].split('=')
+                if len(val) == 1:
+                    filenameOnCommons = params[0].strip()
                 else:
-                    val = params[0].split('=')
-                    if len(val) == 1:
-                        filenameOnCommons = params[0].strip()
-                    else:
-                        filenameOnCommons = val[1].strip()
-                return filenameOnCommons
+                    filenameOnCommons = val[1].strip()
+            return filenameOnCommons

     def run(self):
         """Run the bot."""

--
To view, visit https://gerrit.wikimedia.org/r/558554
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb76b359b86420741f432d3d22fc12d08854a26b
Gerrit-Change-Number: 558554
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Dalba <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Framawiki <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to