Dalba has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/373724 )
Change subject: login.py: Unpack entry into variables instead of overwriting
itself
......................................................................
login.py: Unpack entry into variables instead of overwriting itself
This makes the code easier to follow and developers won't need to remember
what each entry item means when examining the code.
Change-Id: Ide50f0fd7d1baaa875907a17ed1e25801b6d472a
---
M pywikibot/login.py
1 file changed, 10 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/24/373724/1
diff --git a/pywikibot/login.py b/pywikibot/login.py
index fefbda7..836d385 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -265,20 +265,16 @@
'given)'.format(line_nr, entry), _PasswordFileWarning)
continue
- # When the tuple is inverted the default family and code can be
- # easily appended which makes the next condition easier as it does
- # not need to know if it's using the default value or not.
- entry = list(entry[::-1]) + [self.site.family.name,
- self.site.code][len(entry) - 2:]
-
- if (normalize_username(entry[1]) == self.username and
- entry[2] == self.site.family.name and
- entry[3] == self.site.code):
- if isinstance(entry[0], basestring):
- self.password = entry[0]
- elif isinstance(entry[0], BotPassword):
- self.password = entry[0].password
- self.login_name = entry[0].login_name(self.username)
+ password, username, family, code = list(entry[::-1]) + [
+ self.site.family.name, self.site.code][len(entry) - 2:]
+ if (normalize_username(username) == self.username and
+ family == self.site.family.name and
+ code == self.site.code):
+ if isinstance(password, basestring):
+ self.password = password
+ elif isinstance(password, BotPassword):
+ self.password = password.password
+ self.login_name = password.login_name(self.username)
else:
warn('Invalid password format', _PasswordFileWarning)
password_f.close()
--
To view, visit https://gerrit.wikimedia.org/r/373724
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide50f0fd7d1baaa875907a17ed1e25801b6d472a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits