jenkins-bot has submitted this change and it was merged.
Change subject: Allow site-specific, language-agnostic password file entries
......................................................................
Allow site-specific, language-agnostic password file entries
Allow defining entries in the password file that are specific
to a site but not to a language on that site.
Change-Id: I1390e0cc8ff72ee165bf115ef3c9d69e7d2f35af
---
M pywikibot/login.py
1 file changed, 15 insertions(+), 8 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index aead4be..43e8123 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -131,9 +131,11 @@
Use chmod 600 password-file.
All lines below should be valid Python tuples in the form
- (code, family, username, password) or (username, password)
- to set a default password for an username. Default usernames
- should occur above specific usernames.
+ (code, family, username, password),
+ (family, username, password) or
+ (username, password)
+ to set a default password for an username. The last matching entry will
+ be used, so default usernames should occur above specific usernames.
If the username or password contain non-ascii characters, they
should be stored using the utf-8 encoding.
@@ -142,21 +144,26 @@
(u"my_username", u"my_default_password")
(u"my_sysop_user", u"my_sysop_password")
- (u"en", u"wikipedia", u"my_en_user",
u"my_en_pass")
+ (u"wikipedia", u"my_wikipedia_user",
u"my_wikipedia_pass")
+ (u"en", u"wikipedia", u"my_en_wikipedia_user",
u"my_en_wikipedia_pass")
"""
password_f = open(config.password_file)
for line in password_f:
if not line.strip():
continue
entry = eval(line.decode('utf-8'))
- if len(entry) == 2: # for default userinfo
- if entry[0] == self.username:
- self.password = entry[1]
- elif len(entry) == 4: # for userinfo included code and family
+ if len(entry) == 4: # for userinfo included code and family
if entry[0] == self.site.code and \
entry[1] == self.site.family.name and \
entry[2] == self.username:
self.password = entry[3]
+ elif len(entry) == 3: # for userinfo included family
+ if entry[0] == self.site.family.name and \
+ entry[1] == self.username:
+ self.password = entry[2]
+ elif len(entry) == 2: # for default userinfo
+ if entry[0] == self.username:
+ self.password = entry[1]
password_f.close()
def login(self, retry=False):
--
To view, visit
https://gerrit.wikimedia.org/r/127453
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1390e0cc8ff72ee165bf115ef3c9d69e7d2f35af
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Gallaecio <adriyetichaves(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>