jenkins-bot has submitted this change and it was merged.
Change subject: [Bugfix] Revision.timestamp is a pwb Timestamp not ISOformat string
......................................................................
[Bugfix] Revision.timestamp is a pwb Timestamp not ISOformat string
- rewrite UserEditFilterGenerator
- use page revisions generator instead of getLatestEditors
- introduce max_revision_depth parameter for further extensions
- remember Revision.timestamp is already a pywikibot.Timestamp
- "found and not skip or not found and skip" is a xor operation.
We can simplify it with "found ^ skip" or better with
"found != skip"
- We stop iteration after time limit is exceeded
Change-Id: I525f9ed1c71cb502514afe388dc05b8f1dc3c205
---
M scripts/template.py
1 file changed, 15 insertions(+), 14 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/template.py b/scripts/template.py
index de98b32..f82d097 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -100,8 +100,8 @@
#
# (C) Daniel Herding, 2004
# (C) Rob W.W. Hooft, 2003-2005
-# (C) xqt, 2009-2014
-# (C) Pywikibot team, 2004-2014
+# (C) xqt, 2009-2015
+# (C) Pywikibot team, 2004-2015
#
# Distributed under the terms of the MIT license.
#
@@ -114,31 +114,31 @@
from scripts import replace
-def UserEditFilterGenerator(generator, username, timestamp=None, skip=False):
+def UserEditFilterGenerator(generator, username, timestamp=None, skip=False,
+ max_revision_depth=None):
"""
Generator which will yield Pages modified by username.
- It only looks at the last 100 editors.
+ It only looks at the last editors given by max_revision_depth.
If timestamp is set in MediaWiki format JJJJMMDDhhmmss, older edits are
- ignored
+ ignored.
If skip is set, pages edited by the given user are ignored otherwise only
- pages edited by this user are given back
-
+ pages edited by this user are given back.
"""
if timestamp:
ts = pywikibot.Timestamp.fromtimestampformat(timestamp)
+ else:
+ ts = pywikibot.Timestamp.min
for page in generator:
- editors = page.getLatestEditors(limit=100)
found = False
- for ed in editors:
- uts = pywikibot.Timestamp.fromISOformat(ed['timestamp'])
- if not timestamp or uts >= ts:
- if username == ed['user']:
+ for ed in page.revisions(total=max_revision_depth):
+ if ed.timestamp >= ts:
+ if username == ed.user:
found = True
break
else:
break
- if found and not skip or not found and skip:
+ if found != bool(skip): # xor operation
yield page
else:
pywikibot.output(u'Skipping %s' % page.title(asLink=True))
@@ -378,7 +378,8 @@
gen = pagegenerators.CombinedPageGenerator(gens)
gen = pagegenerators.DuplicateFilterPageGenerator(gen)
if user:
- gen = UserEditFilterGenerator(gen, user, timestamp, skip)
+ gen = UserEditFilterGenerator(gen, user, timestamp, skip,
+ max_revision_depth=100)
if not genFactory.gens:
# make sure that proper namespace filtering etc. is handled
--
To view, visit https://gerrit.wikimedia.org/r/188994
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I525f9ed1c71cb502514afe388dc05b8f1dc3c205
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: template.py: fix docstring
......................................................................
template.py: fix docstring
Fix parameter name in docstring:
replacements -> templates
Change-Id: Ib4cd879a58cdba24107536e1096ef220b6f17fd0
---
M scripts/template.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/template.py b/scripts/template.py
index b1054e4..dde75ad 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -201,10 +201,10 @@
@param generator: the pages to work on
@type generator: iterable
- @param replacements: a dictionary which maps old template names to
+ @param templates: a dictionary which maps old template names to
their replacements. If remove or subst is True, it maps the
names of the templates that should be removed/resolved to None.
- @type replacements: dict
+ @type templates: dict
"""
self.availableOptions.update({
'subst': False,
--
To view, visit https://gerrit.wikimedia.org/r/192693
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4cd879a58cdba24107536e1096ef220b6f17fd0
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Deprecate nocapitalize and case
......................................................................
[IMPROV] Deprecate nocapitalize and case
Instead of a static list in the Family file the API should be queried.
All scripts use the Namespace object and APISite itself does check the
Namespace object of the main namespace. The Family class does use a
property which buffers the current state but reads from it will issue a
deprecation warning.
This also deprecates case() as the namespace case should be used if
possible (which is now always usable).
Change-Id: If33ee82d5d9bf657ee36139c409f347b622d3b71
---
M pywikibot/family.py
M pywikibot/page.py
M pywikibot/site.py
M pywikibot/textlib.py
M pywikibot/tools/__init__.py
M scripts/category.py
M scripts/cosmetic_changes.py
M scripts/image.py
M scripts/template.py
9 files changed, 55 insertions(+), 34 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 435e5b0..01a6ac7 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -26,7 +26,7 @@
import pywikibot
from pywikibot import config2 as config
-from pywikibot.tools import deprecated, deprecate_arg
+from pywikibot.tools import deprecated, deprecate_arg, issue_deprecation_warning
from pywikibot.exceptions import Error, UnknownFamily, FamilyMaintenanceWarning
logger = logging.getLogger("pywiki.wiki.family")
@@ -701,8 +701,8 @@
# 'en': "Disambiguation"
self.disambcatname = {}
- # On most wikis page names must start with a capital letter, but some
- # languages don't use this.
+ # DEPRECATED, stores the code of the site which have a case sensitive
+ # main namespace. Use the Namespace given from the Site instead
self.nocapitalize = []
# attop is a list of languages that prefer to have the interwiki
@@ -853,6 +853,20 @@
_families = {}
+ def __getattribute__(self, name):
+ """
+ Check if attribute is deprecated and warn accordingly.
+
+ This is necessary as subclasses could prevent that message by using a
+ class variable. Only penalize getting it because it must be set so that
+ the backwards compatibility is still available.
+ """
+ if name == 'nocapitalize':
+ issue_deprecation_warning('nocapitalize',
+ "APISite.siteinfo['case'] or "
+ "Namespace.case == 'case-sensitive'", 2)
+ return super(Family, self).__getattribute__(name)
+
@staticmethod
@deprecate_arg('fatal', None)
def load(fam=None):
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1f4c866..f088d82 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4537,12 +4537,7 @@
raise pywikibot.InvalidTitle("The link does not contain a page "
"title")
- if hasattr(self._site.namespaces[self._namespace], 'case'):
- case = self._site.namespaces[self._namespace].case
- else:
- case = self._site.case()
-
- if case == 'first-letter':
+ if self._site.namespaces[self._namespace].case == 'first-letter':
t = t[:1].upper() + t[1:]
self._title = t
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 2c36ffa..87cd7f1 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -367,8 +367,8 @@
@classmethod
def builtin_namespaces(cls, use_image_name=False):
"""Return a dict of the builtin namespaces."""
- return dict([(i, cls(i, use_image_name=use_image_name))
- for i in range(-2, 16)])
+ return dict((i, cls(i, use_image_name=use_image_name, case='first-letter'))
+ for i in range(-2, 16))
@staticmethod
def normalize_name(name):
@@ -535,7 +535,6 @@
raise UnknownSite(u"Language '%s' does not exist in family %s"
% (self.__code, self.__family.name))
- self.nocapitalize = self.code in self.family.nocapitalize
self._username = [normalize_username(user), normalize_username(sysop)]
self.use_hard_category_redirects = (
@@ -544,6 +543,11 @@
# following are for use with lock_page and unlock_page methods
self._pagemutex = threading.Lock()
self._locked_pages = []
+
+ @property
+ @deprecated("APISite.siteinfo['case'] or Namespace.case == 'case-sensitive'")
+ def nocapitalize(self):
+ return self.siteinfo['case'] == 'case-sensitive'
@property
def throttle(self):
@@ -919,7 +923,7 @@
name2 = name2.strip()
# If the namespace has a case definition it's overriding the site's
# case definition
- if (ns1_obj.case if hasattr(ns1_obj, 'case') else self.case()) == 'first-letter':
+ if ns1_obj.case == 'first-letter':
name1 = name1[:1].upper() + name1[1:]
name2 = name2[:1].upper() + name2[1:]
return name1 == name2
@@ -2155,6 +2159,9 @@
if is_mw114:
canonical_name = nsdata.pop('canonical')
+ if 'case' not in nsdata:
+ nsdata['case'] = self.siteinfo['case']
+
namespace = Namespace(ns, canonical_name, custom_name,
use_image_name=not is_mw114,
**nsdata)
@@ -2205,8 +2212,11 @@
"""Site information dict."""
return self._siteinfo
+ @deprecated('use siteinfo or Namespace instance')
def case(self):
"""Return this site's capitalization rule."""
+ # This is the global setting via $wgCapitalLinks, it is used whenever
+ # the namespaces don't propagate the namespace specific value.
return self.siteinfo['case']
def dbName(self):
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 372e16e..69c67d8 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -779,7 +779,7 @@
# title might contain regex special characters
title = re.escape(title)
# title might not be capitalized correctly on the wiki
- if title[0].isalpha() and not site.nocapitalize:
+ if title[0].isalpha() and site.namespaces[14].case == 'first-letter':
title = "[%s%s]" % (title[0].upper(), title[0].lower()) + title[1:]
# spaces and underscores in page titles are interchangeable and collapsible
title = title.replace(r"\ ", "[ _]+").replace(r"\_", "[ _]+")
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 1c879f2..051349f 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -798,6 +798,16 @@
return outer_wrapper
+def issue_deprecation_warning(name, instead, depth):
+ """Issue a deprecation warning."""
+ if instead:
+ warn(u'{0} is deprecated, use {1} instead.'.format(name, instead),
+ DeprecationWarning, depth + 1)
+ else:
+ warn(u'{0} is deprecated.'.format(name), _NotImplementedWarning,
+ depth + 1)
+
+
@add_full_name
def deprecated(*args, **kwargs):
"""Decorator to output a deprecation warning.
@@ -825,12 +835,7 @@
"""
name = obj.__full_name__
depth = get_wrapper_depth(wrapper) + 1
- if instead:
- warn(u"%s is deprecated, use %s instead." % (name, instead),
- DeprecationWarning, depth)
- else:
- warn(u"%s is deprecated." % name,
- _NotImplementedWarning, depth)
+ issue_deprecation_warning(name, instead, depth)
return obj(*args, **kwargs)
if not __debug__:
@@ -1042,7 +1047,7 @@
@rtype: callable
"""
def call(*a, **kw):
- warn(warn_message, DeprecationWarning, 2)
+ issue_deprecation_warning(old_name, new_name, 2)
return target(*a, **kw)
if target_module is None:
target_module = target.__module__
@@ -1057,11 +1062,8 @@
if class_name:
target_module += class_name + '.'
source_module += class_name + '.'
- warn_message = ('{source}{old} is deprecated, use {target}{new} '
- 'instead.').format(new=target.__name__,
- old=old_name or target.__name__,
- target=target_module,
- source=source_module)
+ old_name = source_module + (old_name or target.__name__)
+ new_name = target_module + target.__name__
if not __debug__:
return target
diff --git a/scripts/category.py b/scripts/category.py
index 4e2fcc2..1db584f 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -351,7 +351,7 @@
for cat in cats:
pywikibot.output(u"* %s" % cat.title())
newcat = self.newcat
- if not self.current_page.site.nocapitalize:
+ if self.namespaces[14].case == 'first-letter':
newcat = newcat[:1].upper() + newcat[1:]
catpl = pywikibot.Category(self.current_page.site, newcat)
if catpl in cats:
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 04a19e6..68622b2 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -522,8 +522,9 @@
else:
# Try to capitalize the first letter of the title.
# Not useful for languages that don't capitalize nouns.
- # TODO: Determine which languages this is suitable for
- # perhaps using self.site.nocapitalize
+ # TODO: Add a configuration variable for each site,
+ # which determines if the link target is written in
+ # uppercase
if self.site.sitename() == 'wikipedia:de':
titleWithSection = (titleWithSection[0].upper() +
titleWithSection[1:])
@@ -653,7 +654,7 @@
new = ''
else:
new = '{{%s}}' % new
- if not self.site.nocapitalize:
+ if self.namespaces[10].case == 'first-letter':
old = '[' + old[0].upper() + old[0].lower() + ']' + old[1:]
text = textlib.replaceExcept(
text,
diff --git a/scripts/image.py b/scripts/image.py
index fb26ad2..08efc95 100644
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -137,7 +137,7 @@
replacements = []
- if not self.site.nocapitalize:
+ if self.site.namespaces[6].case == 'first-letter':
case = re.escape(self.old_image[0].upper() +
self.old_image[0].lower())
escaped = '[' + case + ']' + re.escape(self.old_image[1:])
diff --git a/scripts/template.py b/scripts/template.py
index 25aad55..b1054e4 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -173,11 +173,10 @@
# regular expression to find the original template.
# {{vfd}} does the same thing as {{Vfd}}, so both will be found.
# The old syntax, {{msg:vfd}}, will also be found.
- # TODO: check site.nocapitalize()
templatePatterns = []
for template in self.templates:
templatePattern = template.title(withNamespace=False)
- if not pywikibot.Site().nocapitalize:
+ if mysite.namespaces[10].case == 'first-letter':
templatePattern = '[%s%s]%s' % (templatePattern[0].upper(),
templatePattern[0].lower(),
templatePattern[1:])
@@ -250,7 +249,7 @@
site = pywikibot.Site()
for old, new in self.templates.items():
namespaces = list(site.namespace(10, all=True))
- if not site.nocapitalize:
+ if site.namespaces[10].case == 'first-letter':
pattern = '[' + \
re.escape(old[0].upper()) + \
re.escape(old[0].lower()) + \
--
To view, visit https://gerrit.wikimedia.org/r/190619
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If33ee82d5d9bf657ee36139c409f347b622d3b71
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Redirect: Use dynamic interwiki prefix
......................................................................
[IMPROV] Redirect: Use dynamic interwiki prefix
Instead of guessing that the interwiki prefix is the same as a language
in the family, it is parsing it using the Link class. This also
separates the link label, section and automatically chooses the correct
capitalization.
Change-Id: I36e5c0e9d3ca0af6813a70851159445bc3285253
---
M scripts/redirect.py
1 file changed, 27 insertions(+), 30 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 225d231..c29fa88 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -82,6 +82,12 @@
from pywikibot import i18n, xmlreader, Bot
+def space_to_underscore(link):
+ """Convert spaces to underscore."""
+ # previous versions weren't expecting spaces but underscores
+ return link.canonical_title().replace(' ', '_')
+
+
class RedirectGenerator:
"""Redirect generator."""
@@ -130,45 +136,36 @@
not in self.namespaces:
continue
if alsoGetPageTitles:
- pageTitles.add(entry.title.replace(' ', '_'))
+ pageTitles.add(space_to_underscore(pywikibot.Link(entry.title, self.site)))
m = redirR.match(entry.text)
if m:
target = m.group(1)
# There might be redirects to another wiki. Ignore these.
- for code in self.site.family.langs.keys():
- if target.startswith('%s:' % code) \
- or target.startswith(':%s:' % code):
- if code == self.site.language():
- # link to our wiki, but with the lang prefix
- target = target[(len(code) + 1):]
- if target.startswith(':'):
- target = target[1:]
- else:
- pywikibot.output(
- u'NOTE: Ignoring %s which is a redirect to %s:'
- % (entry.title, code))
- target = None
- break
+ target_link = pywikibot.Link(target, self.site)
+ try:
+ target_link.parse()
+ except pywikibot.SiteDefinitionError as e:
+ pywikibot.log(e)
+ pywikibot.output(
+ u'NOTE: Ignoring {0} which is a redirect ({1}) to an '
+ u'unknown site.'.format(entry.title, target))
+ target_link = None
+ else:
+ if target_link.site != self.site:
+ pywikibot.output(
+ u'NOTE: Ignoring {0} which is a redirect to '
+ u'another site {1}.'.format(entry.title, target_link.site))
+ target_link = None
# if the redirect does not link to another wiki
- if target:
- source = entry.title.replace(' ', '_')
- target = target.replace(' ', '_')
- # remove leading and trailing whitespace
- target = target.strip('_')
- # capitalize the first letter
- if not pywikibot.Site().nocapitalize:
- source = source[:1].upper() + source[1:]
- target = target[:1].upper() + target[1:]
- if '#' in target:
- target = target[:target.index('#')].rstrip("_")
- if '|' in target:
+ if target_link and target_link.title:
+ source = pywikibot.Link(entry.title, self.site)
+ if target_link.anchor:
pywikibot.output(
u'HINT: %s is a redirect with a pipelink.'
% entry.title)
- target = target[:target.index('|')].rstrip("_")
- if target: # in case preceding steps left nothing
- redict[source] = target
+ redict[space_to_underscore(source)] = (
+ space_to_underscore(target_link))
if alsoGetPageTitles:
return redict, pageTitles
else:
--
To view, visit https://gerrit.wikimedia.org/r/190658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I36e5c0e9d3ca0af6813a70851159445bc3285253
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Tests: Don't test patrol with revid pre 1.22
......................................................................
[FIX] Tests: Don't test patrol with revid pre 1.22
In MediaWiki versions before 1.22 it's not possible to use patrol with
revid, so don't use the revid.
Change-Id: Ia8d4d67fc6ca40330fa102ddb0e339d9934fd280
---
M tests/site_tests.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index b3ac597..ac60018 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1327,9 +1327,13 @@
result = result[0]
self.assertIsInstance(result, dict)
+ params = {'rcid': 0}
+ if mysite.version() >= MediaWikiVersion('1.22'):
+ params['revid'] = [0, 1]
+
try:
# no such rcid, revid or too old revid
- result = list(mysite.patrol(rcid=0, revid=[0, 1]))
+ result = list(mysite.patrol(**params))
except api.APIError as error:
if error.code == u'badtoken':
raise unittest.SkipTest(error)
--
To view, visit https://gerrit.wikimedia.org/r/192191
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia8d4d67fc6ca40330fa102ddb0e339d9934fd280
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2015
Status: Broken
Duration: 48 minutes and 35 seconds
Commit: eba63a3 (master)
Author: Fabian Neundorf
Message: [FIX] UI: Ensure printing message before querying
In Python (at least 3.4.2), the message doesn't get flushed before the
getpass call, so that the user doesn't get any question and any inputs
will be invisible. It only gets visible after exiting the getpass call.
Bug: T90338
Change-Id: Ie19239bca1ba5fad510d8a03bf248b6a6819d0a8
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/33a1c481884d...eba63a37…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/51751461
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] UI: Ensure printing message before querying
......................................................................
[FIX] UI: Ensure printing message before querying
In Python (at least 3.4.2), the message doesn't get flushed before the
getpass call, so that the user doesn't get any question and any inputs
will be invisible. It only gets visible after exiting the getpass call.
Bug: T90338
Change-Id: Ie19239bca1ba5fad510d8a03bf248b6a6819d0a8
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 7 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 0ca9028..d6b9ba2 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -7,10 +7,12 @@
#
__version__ = '$Id$'
-from . import transliteration
+import getpass
+import logging
import re
import sys
-import logging
+
+from . import transliteration
import pywikibot
from pywikibot import config
from pywikibot.bot import VERBOSE, INFO, STDOUT, INPUT, WARNING
@@ -210,7 +212,9 @@
self.output(question + ' ')
try:
if password:
- import getpass
+ # Python 3 requires that stderr gets flushed, otherwise is the
+ # message only visible after the query.
+ self.stderr.flush()
text = getpass.getpass('')
else:
text = self._raw_input()
--
To view, visit https://gerrit.wikimedia.org/r/192206
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie19239bca1ba5fad510d8a03bf248b6a6819d0a8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>