Xqt has submitted this change and it was merged.
Change subject: Bug 55610 - time data error
......................................................................
Bug 55610 - time data error
Removed timestamp format conversion in xmlreader.py
[now in will be returned in ISO 8601 (no timezone), as from API]
Conversion from ISO 8601 (no timezone) to MediaWiki format
is done in wikipedia.py, using parsetime2stamp().
Change-Id: I0ce152b2bb85a33a0b91b2b95879f9a90a4268f4
---
M wikipedia.py
M xmlreader.py
2 files changed, 4 insertions(+), 14 deletions(-)
Approvals:
Xqt: Looks good to me, approved
diff --git a/wikipedia.py b/wikipedia.py
index 12eee21..1b27881 100644
--- a/wikipedia.py
+++ b/wikipedia.py
@@ -5105,7 +5105,7 @@
# Sometimes query does not contains revisions
# or some pages are missing. Deactivate api call and use the
# old API special:export
- if self.site.has_api() and logger.isEnabledFor(DEBUG):
+ if self.site.has_api() and logger.isEnabledFor(DEBUG):
while True:
try:
data = self.getDataApi()
@@ -5200,11 +5200,8 @@
page2._revisionId = revisionId
page2._editTime = parsetime2stamp(timestamp)
page2._versionhistory = [
- (revisionId,
- time.strftime("%Y-%m-%dT%H:%M:%SZ",
- time.strptime(str(timestamp),
- "%Y%m%d%H%M%S")),
- username, entry.comment)]
+ (revisionId, timestamp, username, entry.comment)
+ ]
section = page2.section()
# Store the content
page2._contents = text
diff --git a/xmlreader.py b/xmlreader.py
index 344ddf5..d4568af 100644
--- a/xmlreader.py
+++ b/xmlreader.py
@@ -189,18 +189,11 @@
text = self.text.rstrip('\n ')
# Replace newline by cr/nl
text = u'\r\n'.join(text.split('\n'))
- # Decode the timestamp
- timestamp = (self.timestamp[0:4]+
- self.timestamp[5:7]+
- self.timestamp[8:10]+
- self.timestamp[11:13]+
- self.timestamp[14:16]+
- self.timestamp[17:19])
self.title = self.title.strip()
# Report back to the caller
entry = XmlEntry(self.title, self.ns, self.id,
text, self.username,
- self.ipedit, timestamp,
+ self.ipedit, self.timestamp,
self.editRestriction, self.moveRestriction,
self.revisionid, self.comment, self.isredirect)
self.inRevisionTag = False
--
To view, visit https://gerrit.wikimedia.org/r/89322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ce152b2bb85a33a0b91b2b95879f9a90a4268f4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Fix normalization of template name in harvest_template
......................................................................
Fix normalization of template name in harvest_template
bug: 55122
Change-Id: Ie5969c5ac07c0a0f2b8a104f16513e24f0aa796a
---
M scripts/harvest_template.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
Multichill: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index 89b034a..9cf59a1 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -107,8 +107,11 @@
pagetext = page.get()
templates = pywikibot.extract_templates_and_params(pagetext)
for (template, fielddict) in templates:
+ # Clean up template
+ template = pywikibot.Page(page.site, template,
+ ns=10).title(withNamespace=False)
# We found the template we were looking for
- if template.replace(u'_', u' ') in self.templateTitles:
+ if template in self.templateTitles:
for field, value in fielddict.items():
field = field.strip()
value = value.strip()
--
To view, visit https://gerrit.wikimedia.org/r/89046
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5969c5ac07c0a0f2b8a104f16513e24f0aa796a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Rewritten handling of generic integer arguments
......................................................................
Rewritten handling of generic integer arguments
Change-Id: Ic45856cc7ec894da67d97f75a38638b0806e5db4
---
M pywikibot/bot.py
1 file changed, 11 insertions(+), 12 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 8aaa050..ba93c5b 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -622,17 +622,15 @@
import daemonize
daemonize.daemonize(redirect_std=arg[11:])
else:
- # the argument depends numerical config settings
- cmd = []
- if ':' in arg:
- cmd = arg[1:].split(':')
- if len(cmd) == 2 and len(cmd[1]) > 0 and \
- hasattr(config, cmd[0]) and \
- type(getattr(config, cmd[0])) == int:
- setattr(config, cmd[0], cmd[1])
- # the argument is not global. Let the specific bot script care
- # about it.
- else:
+ # the argument depends on numerical config settings
+ try:
+ _arg, _val = arg[1:].split(':')
+ # explicitly check for int (so bool doesn't match)
+ if type(getattr(config, _arg)) is not int:
+ raise TypeError
+ setattr(config, _arg, int(_val))
+ except (ValueError, TypeError) as exc:
+ # argument not global -> specific bot script will take care
nonGlobalArgs.append(arg)
if username:
@@ -647,7 +645,8 @@
# have to - some git versions (like 1.7.0.4) seem to treat lines
# containing just `$Id:` as if they were ident lines (see
# gitattributes(5)) leading to unwanted behaviour like automatic
- # replacement with `$Id$` or `$Id$`.
+ # replacement with `$Id$`
+ # or `$Id$`.
m = re.search(r"\$Id"
r": (\w+) \$", ver)
pywikibot.output(u'Pywikipediabot r%s' % m.group(1))
--
To view, visit https://gerrit.wikimedia.org/r/87639
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic45856cc7ec894da67d97f75a38638b0806e5db4
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: login: add logout option and hidden password note
......................................................................
login: add logout option and hidden password note
- scripts/login.py now has the -logout option to log out
- when asking for a password, pywikibot/login.py will note no characters
will be shown
Change-Id: If25cb90bfdde8fac0ed6ad8a0c224e5f7e811fcb
---
M pywikibot/login.py
M pywikibot/site.py
M scripts/login.py
3 files changed, 29 insertions(+), 6 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 49cebaa..872ad68 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -161,10 +161,9 @@
# As we don't want the password to appear on the screen, we set
# password = True
self.password = pywikibot.input(
- u'Password for user %(name)s on %(site)s:'
+ u'Password for user %(name)s on %(site)s (no characters will be shown):'
% {'name': self.username, 'site': self.site},
password=True)
-
# self.password = self.password.encode(self.site.encoding())
pywikibot.output(u"Logging in to %(site)s as %(name)s"
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 13477b0..52d97fe 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -883,6 +883,14 @@
forceLogin = login # alias for backward-compatibility
+ def logout(self):
+ uirequest = api.Request(site=self, action="logout")
+ uidata = uirequest.submit()
+ self._loginstatus = LoginStatus.NOT_LOGGED_IN
+ if hasattr(self, "_userinfo"):
+ del self._userinfo
+ self.getuserinfo()
+
def getuserinfo(self):
"""Retrieve userinfo from site and store in _userinfo attribute.
diff --git a/scripts/login.py b/scripts/login.py
index 53638e6..02a4590 100755
--- a/scripts/login.py
+++ b/scripts/login.py
@@ -8,9 +8,17 @@
Parameters:
+ -family:FF
+ -lang:LL Log in to the LL language of the FF family.
+ Example: -family:wiktionary -lang:fr will log you in at
+ fr.wiktionary.org.
+
-all Try to log in on all sites where a username is defined in
user-config.py.
+ -logout Log out of the curren site. Combine with -all to log out of
+ all sites, or with -family and -lang to log out of a specific
+ site.
-force Ignores if the user is already logged in, and tries to log in.
@@ -57,10 +65,11 @@
password = None
sysop = False
logall = False
+ logout = False
for arg in pywikibot.handleArgs(*args):
if arg.startswith("-pass"):
if len(arg) == 5:
- password = pywikibot.input(u'Password for all accounts:',
+ password = pywikibot.input(u'Password for all accounts (no characters will be shown):',
password=True)
else:
password = arg[6:]
@@ -71,6 +80,8 @@
elif arg == "-force":
pywikibot.output(u"To force a re-login, please delete the revelant lines from '%s' (or the entire file) and try again." %
join(config.base_dir, 'pywikibot.lwp'))
+ elif arg == "-logout":
+ logout = True
else:
pywikibot.showHelp('login')
return
@@ -86,13 +97,18 @@
for lang in namedict[familyName]:
try:
site = pywikibot.getSite(code=lang, fam=familyName)
- site.login()
-
+ if logout:
+ site.logout()
+ else:
+ site.login()
user = site.user()
if user:
pywikibot.output(u"Logged in on %(site)s as %(user)s." % locals())
else:
- pywikibot.output(u"Not logged in on %(site)s." % locals())
+ if logout:
+ pywikibot.output(u"Logged out of %(site)s." % locals())
+ else:
+ pywikibot.output(u"Not logged in on %(site)s." % locals())
except NoSuchSite:
pywikibot.output(u'%s.%s is not a valid site, please remove it'
u' from your config' % (lang, familyName))
--
To view, visit https://gerrit.wikimedia.org/r/79730
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If25cb90bfdde8fac0ed6ad8a0c224e5f7e811fcb
Gerrit-PatchSet: 12
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot