jenkins-bot merged this change.

View Change

Approvals: Framawiki: Looks good to me, approved jenkins-bot: Verified
[fix] Return None in LoginManager.getCookie()

- Du to pep8 an explicit return statement should be present in a function
- Simplify site assingment (update from compat)
- Simplify continuous if statements
- Use single quotes in Example

Bug: T209193
Change-Id: I8ceae91cec9f009d8f8e3b45391100fa5722f5bc
---
M pywikibot/login.py
1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/pywikibot/login.py b/pywikibot/login.py
index 0f54a60..73dfad5 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -82,10 +82,7 @@

@raises NoUsername: No username is configured for the requested site.
"""
- if site is not None:
- self.site = site
- else:
- self.site = pywikibot.Site()
+ self.site = site or pywikibot.Site()
if user:
self.username = user
elif sysop:
@@ -193,7 +190,8 @@

@return: cookie data if successful, None otherwise.
"""
- # NOT IMPLEMENTED - see data/api.py for implementation
+ # THIS IS OVERRIDDEN IN data/api.py
+ return None

def storecookiedata(self, data):
"""
@@ -230,12 +228,12 @@

Example::

- ("my_username", "my_default_password")
- ("my_sysop_user", "my_sysop_password")
- ("wikipedia", "my_wikipedia_user", "my_wikipedia_pass")
- ("en", "wikipedia", "my_en_wikipedia_user", "my_en_wikipedia_pass")
- ("my_username", BotPassword(
- "my_BotPassword_suffix", "my_BotPassword_password"))
+ ('my_username', 'my_default_password')
+ ('my_sysop_user', 'my_sysop_password')
+ ('wikipedia', 'my_wikipedia_user', 'my_wikipedia_pass')
+ ('en', 'wikipedia', 'my_en_wikipedia_user', 'my_en_wikipedia_pass')
+ ('my_username', BotPassword(
+ 'my_BotPassword_suffix', 'my_BotPassword_password'))
"""
# Set path to password file relative to the user_config
# but fall back on absolute path for backwards compatibility
@@ -316,14 +314,14 @@
if e.code == 'NotExists':
raise NoUsername("Username '%s' does not exist on %s"
% (self.login_name, self.site))
- elif e.code == 'Illegal':
+ if e.code == 'Illegal':
raise NoUsername("Username '%s' is invalid on %s"
% (self.login_name, self.site))
- elif e.code == 'readapidenied':
+ if e.code == 'readapidenied':
raise NoUsername(
'Username "{0}" does not have read permissions on '
'{1}'.format(self.login_name, self.site))
- elif e.code == 'Failed':
+ if e.code == 'Failed':
raise NoUsername(
'Username "{0}" does not have read permissions on '
'{1}\n.{2}'.format(self.login_name, self.site, e.info))

To view, visit change 473848. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8ceae91cec9f009d8f8e3b45391100fa5722f5bc
Gerrit-Change-Number: 473848
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)