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

Change subject: [bugfix] Fix author_ns_prefix assignment
......................................................................

[bugfix] Fix author_ns_prefix assignment

- bugfix for is_wikisource_author_page which could fail if author_ns
  is 0 or missing in family file because author_ns_prefix is not
  defined previously; return False at the end

detached from I4ef9009c91e485

Change-Id: If9c5c0b636dfb006e4d3a84fd7d3f42b9a1b3627
---
M scripts/patrol.py
1 file changed, 7 insertions(+), 9 deletions(-)

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



diff --git a/scripts/patrol.py b/scripts/patrol.py
index 318c46a..200a7d4 100755
--- a/scripts/patrol.py
+++ b/scripts/patrol.py
@@ -264,21 +264,19 @@
     def is_wikisource_author_page(self, title):
         """Initialise author_ns if site family is 'wikisource' else pass."""
         if self.site.family.name != 'wikisource':
-            return
+            return False

-        author_ns = 0
         try:
             author_ns = self.site.family.authornamespaces[self.site.lang][0]
         except (AttributeError, KeyError):
-            pass
-        if author_ns:
-            author_ns_prefix = self.site.namespace(author_ns)
-        pywikibot.debug('Author ns: {0}; name: {1}'
-                        .format(author_ns, author_ns_prefix), _logger)
-        if title.find(author_ns_prefix + ':') == 0:
-            author_page_name = title[len(author_ns_prefix) + 1:]
+            author_ns = 0
+
+        author_ns_prefix = self.site.namespace(author_ns) + ':'
+        if title.startswith(author_ns_prefix):
+            author_page_name = title[len(author_ns_prefix):]
             verbose_output('Found author ' + author_page_name)
             return True
+        return False
 
     def run(self, feed):
         """Process 'whitelist' page absent in generator."""

--
To view, visit https://gerrit.wikimedia.org/r/524497
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: If9c5c0b636dfb006e4d3a84fd7d3f42b9a1b3627
Gerrit-Change-Number: 524497
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Dalba <[email protected]>
Gerrit-Reviewer: John Vandenberg <[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