jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669096 )
Change subject: [pep8] Line break before a binary operator
......................................................................
[pep8] Line break before a binary operator
https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-aft…
Change-Id: I93cace7af67502d6096fa165ffc9023535fea40b
---
M pywikibot/__init__.py
M pywikibot/bot_choice.py
M pywikibot/cosmetic_changes.py
M pywikibot/data/api.py
M pywikibot/family.py
M pywikibot/page/__init__.py
M pywikibot/site/_apisite.py
M pywikibot/site/_basesite.py
M pywikibot/textlib.py
M pywikibot/version.py
M scripts/category.py
M scripts/download_dump.py
M scripts/noreferences.py
M scripts/weblinkchecker.py
M tests/wikibase_tests.py
15 files changed, 63 insertions(+), 66 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 08d50ef..76d3fe2 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -706,8 +706,8 @@
self.site = site or Site().data_repository()
# also allow entity URIs to be provided via unit parameter
- if isinstance(unit, str) and \
- unit.partition('://')[0] not in ('http', 'https'):
+ if isinstance(unit, str) \
+ and unit.partition('://')[0] not in ('http', 'https'):
raise ValueError("'unit' must be an ItemPage or entity uri.")
if error is None and not self._require_errors(site):
@@ -905,8 +905,8 @@
# pcre regexp: '/^Data:[^\\[\\]#\\\:{|}]+\.tab$/u' for tabular-data
# As we have already checked for existence the following simplified
# check should be enough.
- if not page.title().startswith('Data:') or \
- not page.title().endswith(ending):
+ if not page.title().startswith('Data:') \
+ or not page.title().endswith(ending):
raise ValueError(
"Page must be in 'Data:' namespace and end in '{0}' "
'for {1}.'.format(ending, label))
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 8a9a661..9c2601d 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -286,8 +286,8 @@
if self.replacer.current_link.anchor is None:
kwargs['label'] = self.replacer.current_groups['title']
if self.replacer.current_groups['section']:
- kwargs['label'] += '#' + \
- self.replacer.current_groups['section']
+ kwargs['label'] += '#' \
+ + self.replacer.current_groups['section']
else:
kwargs['label'] = self.replacer.current_link.anchor
return pywikibot.Link.create_separated(
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index d8ea03b..97bbfe3 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -51,7 +51,7 @@
'your_script_name_2']
"""
#
-# (C) Pywikibot team, 2006-2020
+# (C) Pywikibot team, 2006-2021
#
# Distributed under the terms of the MIT license.
#
@@ -801,8 +801,8 @@
exceptions = ['comment', 'math', 'nowiki', 'pre']
builder = _MultiTemplateMatchBuilder(self.site)
- if self.site.family.name in deprecatedTemplates and \
- self.site.code in deprecatedTemplates[self.site.family.name]:
+ if self.site.family.name in deprecatedTemplates \
+ and self.site.code in deprecatedTemplates[self.site.family.name]:
for template in deprecatedTemplates[
self.site.family.name][self.site.code]:
old, new = template
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 4c34108..ae28af0 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -490,8 +490,8 @@
break
else:
param = {}
- assert param['name'] == 'generator' and \
- submodules >= set(param['type'])
+ assert param['name'] == 'generator' \
+ and submodules >= set(param['type'])
def _normalize_modules(self, modules) -> set:
"""Add query+ to any query module name not also in action modules."""
@@ -1846,8 +1846,8 @@
continue
# Phab. tickets T48535, T64126, T68494, T68619
- if code == 'failed-save' and \
- self._is_wikibase_error_retryable(result['error']):
+ if code == 'failed-save' \
+ and self._is_wikibase_error_retryable(result['error']):
self.wait()
continue
@@ -2147,13 +2147,15 @@
n = 0
while True:
self.request[self.continue_name] = offset
- pywikibot.debug('%s: Request: %s' % (
- self.__class__.__name__, self.request), _logger)
+ pywikibot.debug('{}: Request: {}'
+ .format(self.__class__.__name__, self.request),
+ _logger)
data = self.request.submit()
n_items = len(data[self.data_name])
- pywikibot.debug('%s: Retrieved %d items' % (
- self.__class__.__name__, n_items), _logger)
+ pywikibot.debug('{}: Retrieved {} items'
+ .format(self.__class__.__name__, n_items),
+ _logger)
if n_items > 0:
for item in data[self.data_name]:
yield item
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 853be17..262c8c0 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -619,8 +619,8 @@
def category_redirects(self, code, fallback='_default'):
"""Return list of category redirect templates."""
- if not hasattr(self, '_catredirtemplates') or \
- code not in self._catredirtemplates:
+ if not hasattr(self, '_catredirtemplates') \
+ or code not in self._catredirtemplates:
self._get_cr_templates(code, fallback)
return self._catredirtemplates[code]
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 009aeb6..f0585c5 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -293,14 +293,14 @@
else:
target_code = config.mylang
target_family = config.family
- if force_interwiki or \
- (allow_interwiki
- and (self.site.family.name != target_family
- or self.site.code != target_code)):
+ if force_interwiki \
+ or (allow_interwiki
+ and (self.site.family.name != target_family
+ or self.site.code != target_code)):
if self.site.family.name != target_family \
and self.site.family.name != self.site.code:
- title = '%s:%s:%s' % (
- self.site.family.name, self.site.code, title)
+ title = '{site.family.name}:{site.code}:{title}'.format(
+ site=self.site, title=title)
else:
# use this form for sites like commons, where the
# code is the same as the family name
@@ -5344,13 +5344,11 @@
# often be unreachable due to the way web browsers deal
# * with 'relative' URLs. Forbid them explicitly.
- if '.' in t and (
- t in ('.', '..')
- or t.startswith(('./', '../'))
- or '/./' in t
- or '/../' in t
- or t.endswith(('/.', '/..'))
- ):
+ if '.' in t and (t in ('.', '..')
+ or t.startswith(('./', '../'))
+ or '/./' in t
+ or '/../' in t
+ or t.endswith(('/.', '/..'))):
raise pywikibot.InvalidTitle(
"(contains . / combinations): '%s'"
% self._text)
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 72e4325..196bffc 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -4509,8 +4509,8 @@
# TODO: catch and process foreseeable errors
if error.code == 'uploaddisabled':
self._uploaddisabled = True
- elif error.code == 'stashfailed' and \
- 'offset' in error.other:
+ elif error.code == 'stashfailed' \
+ and 'offset' in error.other:
# TODO: Ask MediaWiki to change this
# ambiguous error code.
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py
index e866e06..a46bc22 100644
--- a/pywikibot/site/_basesite.py
+++ b/pywikibot/site/_basesite.py
@@ -76,11 +76,11 @@
pywikibot.log('Site %s instantiated and marked "obsolete" '
'to prevent access' % self)
elif self.__code not in self.languages():
- if self.__family.name in self.__family.langs and \
- len(self.__family.langs) == 1:
+ if self.__family.name in self.__family.langs \
+ and len(self.__family.langs) == 1:
self.__code = self.__family.name
if self.__family == pywikibot.config.family \
- and code == pywikibot.config.mylang:
+ and code == pywikibot.config.mylang:
pywikibot.config.mylang = self.__code
warn('Global configuration variable "mylang" changed to '
'"%s" while instantiating site %s'
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 9df6e0c..7d15da6 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1094,11 +1094,10 @@
separator=separatorstripped)
s = interwikiFormat(new, insite=site)
if s:
- if site.code in site.family.interwiki_attop or \
- '<!-- interwiki at top -->' in oldtext:
+ if site.code in site.family.interwiki_attop \
+ or '<!-- interwiki at top -->' in oldtext:
# do not add separator if interwiki links are on one line
- newtext = s + ('' if site.code
- in site.family.interwiki_on_one_line
+ newtext = s + ('' if site.code in site.family.interwiki_on_one_line
else separator) + s2.replace(marker, '').strip()
else:
# calculate what was after the language links on the page
@@ -1116,8 +1115,8 @@
elif site.code in site.family.categories_last:
cats = getCategoryLinks(s2, site=site)
s2 = removeCategoryLinksAndSeparator(
- s2.replace(marker, cseparatorstripped).strip(), site) + \
- separator + s
+ s2.replace(marker, cseparatorstripped).strip(), site) \
+ + separator + s
newtext = replaceCategoryLinks(s2, cats, site=site,
addOnly=True)
# for Wikitravel's language links position.
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 5667630..20242f5 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -480,8 +480,8 @@
# If builtins or standard_lib is None,
# only include package if a version was found.
- if (builtins is None and name in builtin_packages) or \
- (standard_lib is None and name in std_lib_packages):
+ if builtins is None and name in builtin_packages \
+ or standard_lib is None and name in std_lib_packages:
if 'ver' in info:
data[name] = info
else:
diff --git a/scripts/category.py b/scripts/category.py
index cc868a0..e5876f9 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -710,8 +710,8 @@
else:
pywikibot.log("Didn't move pages/subcategories, because the "
"category page hasn't been moved.")
- if self.oldcat.isEmptyCategory() and self.delete_oldcat and \
- ((self.newcat and self.move_oldcat) or not self.newcat):
+ if self.oldcat.isEmptyCategory() and self.delete_oldcat \
+ and (self.newcat and self.move_oldcat or not self.newcat):
self._delete(can_move_page, can_move_talk)
def _delete(self, moved_page, moved_talk) -> None:
diff --git a/scripts/download_dump.py b/scripts/download_dump.py
index 98517fa..4f38605 100755
--- a/scripts/download_dump.py
+++ b/scripts/download_dump.py
@@ -78,8 +78,8 @@
download_filename = '{wikiname}-{dumpdate}-{filename}'.format_map(
self.opt)
- temp_filename = download_filename + '-' + \
- binascii.b2a_hex(urandom(8)).decode('ascii') + '.part'
+ temp_filename = download_filename + '-' \
+ + binascii.b2a_hex(urandom(8)).decode('ascii') + '.part'
file_final_storepath = os.path.join(
self.opt.storepath, download_filename)
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 20407cc..49fd0f0 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -29,7 +29,7 @@
a list of affected articles
"""
#
-# (C) Pywikibot team, 2007-2020
+# (C) Pywikibot team, 2007-2021
#
# Distributed under the terms of the MIT license.
#
@@ -542,8 +542,8 @@
def lacksReferences(self, text) -> bool:
"""Check whether or not the page is lacking a references tag."""
oldTextCleaned = textlib.removeDisabledParts(text)
- if self.referencesR.search(oldTextCleaned) or \
- self.referencesTagR.search(oldTextCleaned):
+ if self.referencesR.search(oldTextCleaned) \
+ or self.referencesTagR.search(oldTextCleaned):
if self.opt.verbose:
pywikibot.output('No changes necessary: references tag found.')
return False
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index de3885e..ecc2836 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -104,7 +104,7 @@
python pwb.py weblinkchecker -repeat
"""
#
-# (C) Pywikibot team, 2005-2020
+# (C) Pywikibot team, 2005-2021
#
# Distributed under the terms of the MIT license.
#
@@ -517,11 +517,9 @@
content = ''
if archiveURL:
- archiveMsg = '\n' + \
- i18n.twtranslate(
- containingPage.site,
- 'weblinkchecker-archive_msg',
- {'URL': archiveURL})
+ archiveMsg = '\n' + i18n.twtranslate(
+ containingPage.site, 'weblinkchecker-archive_msg',
+ {'URL': archiveURL})
else:
archiveMsg = ''
# The caption will default to "Dead link". But if there
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 9f19a85..4413ffe 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -690,8 +690,8 @@
"""Test WbGeoShape error handling of a non-map page."""
non_data_page = Page(self.commons, 'File:Foo.jpg')
non_map_page = Page(self.commons, 'Data:TemplateData/TemplateData.tab')
- regex = r"^Page must be in 'Data:' namespace and end in '\.map' " + \
- r'for geo-shape\.$'
+ regex = (r"^Page must be in 'Data:' namespace and end in '\.map' "
+ r'for geo-shape\.$')
with self.assertRaisesRegex(ValueError, regex):
pywikibot.WbGeoShape(non_data_page, self.get_repo())
with self.assertRaisesRegex(ValueError, regex):
@@ -766,8 +766,8 @@
"""Test WbTabularData error handling of a non-map page."""
non_data_page = Page(self.commons, 'File:Foo.jpg')
non_map_page = Page(self.commons, 'Data:Lyngby Hovedgade.map')
- regex = r"^Page must be in 'Data:' namespace and end in '\.tab' " + \
- r'for tabular-data\.$'
+ regex = (r"^Page must be in 'Data:' namespace and end in '\.tab' "
+ r'for tabular-data\.$')
with self.assertRaisesRegex(ValueError, regex):
pywikibot.WbTabularData(non_data_page, self.get_repo())
with self.assertRaisesRegex(ValueError, regex):
@@ -1251,8 +1251,8 @@
"""Test ItemPage.from_entity_uri with unexpected item repo."""
repo = self.get_repo()
entity_uri = 'http://test.wikidata.org/entity/Q124'
- regex = r'^The supplied data repository \(.+\) does not ' + \
- r'correspond to that of the item \(.+\)$'
+ regex = (r'^The supplied data repository \(.+\) does not '
+ r'correspond to that of the item \(.+\)$')
with self.assertRaisesRegex(ValueError, regex):
ItemPage.from_entity_uri(repo, entity_uri)
@@ -2028,8 +2028,8 @@
"""Test that page_from_repository method fails."""
site = self.get_site(key)
dummy_item = 'Q1'
- regex = r'^page_from_repository method is not implemented ' + \
- r'for Wikibase .+\.$'
+ regex = (r'^page_from_repository method is not implemented '
+ r'for Wikibase .+\.$')
with self.assertRaisesRegex(NotImplementedError, regex):
site.page_from_repository(dummy_item)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669096
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I93cace7af67502d6096fa165ffc9023535fea40b
Gerrit-Change-Number: 669096
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669009 )
Change subject: [cleanup] remove deprecated Site.language() method in favour of lang property
......................................................................
[cleanup] remove deprecated Site.language() method in favour of lang property
Change-Id: Iee5ee681960957450ac005124011a1982132e417
---
M pywikibot/site/_apisite.py
M tests/site_tests.py
2 files changed, 0 insertions(+), 10 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index d81d35f..72e4325 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -956,11 +956,6 @@
"""Return this site's internal id."""
return self.siteinfo['wikiid']
- @deprecated('APISite.lang', since='20150629', future_warning=True)
- def language(self): # pragma: no cover
- """Return the code for the language of this Site."""
- return self.lang
-
@property
def lang(self):
"""Return the code for the language of this Site."""
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 6535c63..3a5337d 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -65,11 +65,6 @@
self.assertOneDeprecationParts('Calling siteinfo',
'itself as a dictionary')
- def test_language_method(self):
- """Test if the language method returns the same as lang property."""
- self.assertEqual(self.site.language(), self.site.lang)
- self.assertOneDeprecation()
-
def test_allpages_filterredir_True(self):
"""Test that filterredir set to 'only' is deprecated to True."""
for page in self.site.allpages(filterredir='only', total=1):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669009
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iee5ee681960957450ac005124011a1982132e417
Gerrit-Change-Number: 669009
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669007 )
Change subject: [cleanup] Deprecate User.name() method in favour of User.username property
......................................................................
[cleanup] Deprecate User.name() method in favour of User.username property
Show a FutureWarning if deprecated User.name() is used
Change-Id: I5297d35ded399c2759aa65ae9a272467e08837b2
---
M pywikibot/page/__init__.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index d2f8e66..009aeb6 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -2822,7 +2822,7 @@
pywikibot.output(
'This is an autoblock ID, you can only use to unblock it.')
- @deprecated('User.username', since='20160504')
+ @deprecated('User.username', since='20160504', future_warning=True)
def name(self) -> str: # pragma: no cover
"""
The username.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669007
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5297d35ded399c2759aa65ae9a272467e08837b2
Gerrit-Change-Number: 669007
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668344 )
Change subject: [IMPR] Add replacement description to -summary message
......................................................................
[IMPR] Add replacement description to -summary message
To add the replacements to -summary option a %(description)s placeholder
must be used. For example:
-summary:"Bot operated replacement:%(description)s done."
includes all replacements within the summary string like
"Bot operated replacement: (-a +b) done."
Change-Id: I21bb8ce1f53f0155f608e12a4f6b3f3f2dfafada
---
M scripts/replace.py
1 file changed, 14 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index a9187e8..7f4399c 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -57,7 +57,10 @@
-summary:XYZ Set the summary message text for the edit to XYZ, bypassing
the predefined message texts with original and replacements
- inserted. Can't be used with -automaticsummary.
+ inserted. To add the replacements to your summary use the
+ %(description)s placeholder, for example:
+ -summary:"Bot operated replacement: %(description)s"
+ Can't be used with -automaticsummary.
-automaticsummary Uses an automatic summary for all replacements which don't
have a summary defined. Can't be used with -summary.
@@ -640,19 +643,20 @@
summary_messages.add(replacement.edit_summary)
elif replacement.default_summary:
default_summaries.add((replacement.old, replacement.new))
+
summary_messages = sorted(summary_messages)
if default_summaries:
if self.opt.summary:
- summary_messages.insert(0, self.opt.summary)
+ msg = self.opt.summary
else:
- comma = self.site.mediawiki_message('comma-separator')
- default_summary = comma.join(
- '-{0} +{1}'.format(*default_summary)
- for default_summary in default_summaries)
- summary_messages.insert(0, i18n.twtranslate(
- self.site, 'replace-replacing',
- {'description': ' ({0})'.format(default_summary)}
- ))
+ msg = i18n.twtranslate(self.site, 'replace-replacing')
+ comma = self.site.mediawiki_message('comma-separator')
+ default_summary = comma.join(
+ '-{} +{}'.format(*default_summary)
+ for default_summary in default_summaries)
+ desc = {'description': ' ({})'.format(default_summary)}
+ summary_messages.insert(0, msg % desc)
+
semicolon = self.site.mediawiki_message('semicolon-separator')
return semicolon.join(summary_messages)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668344
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I21bb8ce1f53f0155f608e12a4f6b3f3f2dfafada
Gerrit-Change-Number: 668344
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Bináris <wikiposta(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Klein Muçi <kleinmuci(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668107 )
Change subject: [IMPR] simplify code in treat_disamb_only
......................................................................
[IMPR] simplify code in treat_disamb_only
- move code out of try statement in treat_disamb_only
- remove include = False statement; include is False by default
Change-Id: I2c4946299df5ed8ad2e5befdb080eb4897e11e36
---
M scripts/solve_disambiguation.py
1 file changed, 12 insertions(+), 12 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index b8bc74d..65d6edc 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -747,13 +747,6 @@
new_targets = []
try:
text = ref_page.get()
- ignore_reason = self.checkContents(text)
- if ignore_reason:
- pywikibot.output(
- '\n\nSkipping {0} because it contains {1}.\n\n'
- .format(ref_page.title(), ignore_reason))
- else:
- include = True
except pywikibot.IsRedirectPage:
pywikibot.output('{0} is a redirect to {1}'
.format(ref_page.title(), disamb_page.title()))
@@ -792,8 +785,16 @@
pywikibot.output(
'Page [[{0}]] does not seem to exist?! Skipping.'
.format(ref_page.title()))
- include = False
- if include in (True, 'redirect'):
+ else:
+ ignore_reason = self.checkContents(text)
+ if ignore_reason:
+ pywikibot.output(
+ '\n\nSkipping {0} because it contains {1}.\n\n'
+ .format(ref_page.title(), ignore_reason))
+ else:
+ include = True
+
+ if include:
# save the original text so we can show the changes later
original_text = text
n = 0
@@ -817,9 +818,8 @@
foundlink = pywikibot.Link(m.group('title'),
disamb_page.site)
foundlink.parse()
- except pywikibot.Error:
- continue
- except ValueError: # T111513
+ except (pywikibot.Error,
+ ValueError): # T111513
continue
# ignore interwiki links
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668107
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2c4946299df5ed8ad2e5befdb080eb4897e11e36
Gerrit-Change-Number: 668107
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/668747 )
Change subject: [i18n] add i18n support for transferbot
......................................................................
[i18n] add i18n support for transferbot
Bug: T216898
Change-Id: Ia72d384e0914e066558ca585b9b1f5b372b6fc51
---
A transferbot/en.json
A transferbot/qqq.json
2 files changed, 18 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/transferbot/en.json b/transferbot/en.json
new file mode 100644
index 0000000..885de2a
--- /dev/null
+++ b/transferbot/en.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Valhallasw"
+ ]
+ },
+ "transferbot-summary": "Moved page from %(source)s",
+ "transferbot-target": "This page was moved from %(source)s. Its edit history can be viewed at %(history)s"
+}
diff --git a/transferbot/qqq.json b/transferbot/qqq.json
new file mode 100644
index 0000000..a088a9e
--- /dev/null
+++ b/transferbot/qqq.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Xqt"
+ ]
+ },
+ "transferbot-summary": "Edit summary when the bot transfers a page from source page to target. Parameters:\n * %(source)s - link of the source page",
+ "transferbot-target": "A summary which is written to a target page when a content was copied from a source. Parameters:\n %(source)s - link of the source page\n * %(history)s - link of the edit history page"
+}
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/668747
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-Change-Id: Ia72d384e0914e066558ca585b9b1f5b372b6fc51
Gerrit-Change-Number: 668747
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668721 )
Change subject: [IMPR] Avoid deeply nested control statements in login.py script
......................................................................
[IMPR] Avoid deeply nested control statements in login.py script
- avoid deeply nested control statements
- only try creating the site
- use str.format for outputs
Change-Id: I5ddb04894361218f6d5d96c68054e046a11335f2
---
M scripts/login.py
1 file changed, 38 insertions(+), 40 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/login.py b/scripts/login.py
index c289659..a6409f6 100755
--- a/scripts/login.py
+++ b/scripts/login.py
@@ -7,9 +7,8 @@
The following parameters are supported:
- -family:FF
- -lang:LL Log in to the LL language of the FF family.
- Example: -family:wiktionary -lang:fr will log you in at
+ -family:FF Log in to the LL language of the FF family.
+ -lang:LL Example: -family:wiktionary -lang:fr will log you in at
fr.wiktionary.org.
-site:FF:LL Log in to the LL language of the FF family
@@ -54,7 +53,7 @@
subdirectory.
"""
#
-# (C) Pywikibot team, 2003-2020
+# (C) Pywikibot team, 2003-2021
#
# Distributed under the terms of the MIT license.
#
@@ -82,26 +81,24 @@
login_manager.login()
identity = login_manager.identity
if identity is None:
- pywikibot.error('Invalid OAuth info for %(site)s.' %
- {'site': site})
+ pywikibot.error('Invalid OAuth info for {site}.'.format(site=site))
elif site.username() != identity['username']:
- pywikibot.error('Logged in on %(site)s via OAuth as %(wrong)s, '
- 'but expect as %(right)s'
- % {'site': site,
- 'wrong': identity['username'],
- 'right': site.username()})
+ pywikibot.error(
+ 'Logged in on {site} via OAuth as {wrong}, but expect as {right}'
+ .format(site=site,
+ wrong=identity['username'], right=site.username()))
else:
oauth_token = login_manager.consumer_token + login_manager.access_token
- pywikibot.output('Logged in on %(site)s as %(username)s'
- 'via OAuth consumer %(consumer)s'
- % {'site': site,
- 'username': site.username(),
- 'consumer': consumer_key})
- pywikibot.output('NOTE: To use OAuth, you need to copy the '
- 'following line to your user-config.py:')
- pywikibot.output("authenticate['%(hostname)s'] = %(oauth_token)s" %
- {'hostname': site.hostname(),
- 'oauth_token': oauth_token})
+ pywikibot.output('Logged in on {site} as {username}'
+ 'via OAuth consumer {consumer}\n'
+ 'NOTE: To use OAuth, you need to copy the '
+ 'following line to your user-config.py:\n'
+ 'authenticate[{hostname!r}] = {oauth_token}'
+ .format(site=site,
+ username=site.username(),
+ consumer=consumer_key,
+ hostname=site.hostname(),
+ oauth_token=oauth_token))
def main(*args) -> None:
@@ -159,27 +156,28 @@
for lang in namedict[family_name]:
try:
site = pywikibot.Site(code=lang, fam=family_name)
- if oauth:
- _oauth_login(site)
- continue
- if logout:
- site.logout()
- else:
- site.login(autocreate=autocreate)
- user = site.user()
- if user:
- pywikibot.output(
- 'Logged in on {0} as {1}.'.format(site, user))
- else:
- if logout:
- pywikibot.output('Logged out of {0}.'.format(site))
- else:
- pywikibot.output(
- 'Not logged in on {0}.'.format(site))
except SiteDefinitionError:
- pywikibot.output('{0}.{1} is not a valid site, '
- 'please remove it from your config'
+ pywikibot.output('{1}:{0} is not a valid site, '
+ 'please remove it from your user-config'
.format(lang, family_name))
+ continue
+
+ if oauth:
+ _oauth_login(site)
+ continue
+
+ if logout:
+ site.logout()
+ else:
+ site.login(autocreate=autocreate)
+
+ user = site.user()
+ if user:
+ pywikibot.output('Logged in on {} as {}.'.format(site, user))
+ elif logout:
+ pywikibot.output('Logged out of {}.'.format(site))
+ else:
+ pywikibot.output('Not logged in on {}.'.format(site))
if __name__ == '__main__':
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668721
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5ddb04894361218f6d5d96c68054e046a11335f2
Gerrit-Change-Number: 668721
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668698 )
Change subject: [cleanup] deprecate register_family_file function()
......................................................................
[cleanup] deprecate register_family_file function()
deprecate config2.register_family_file function()
It can be easily replaced by this setting:
'family_files[family_name] = file_path'
Also drop recently introduced user_families dict
Change-Id: I91662836c735e85d545a4c5c221306cb9f81dd69
---
M pywikibot/config2.py
1 file changed, 11 insertions(+), 12 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 91204be..022d88d 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -47,9 +47,9 @@
from warnings import warn
from pywikibot.__metadata__ import __version__ as pwb_version
-from pywikibot.backports import Dict, List, Tuple
+from pywikibot.backports import Dict, List, removesuffix, Tuple
from pywikibot.logging import error, output, warning
-from pywikibot.tools import issue_deprecation_warning
+from pywikibot.tools import issue_deprecation_warning, deprecated
OSWIN32 = (sys.platform == 'win32')
@@ -388,6 +388,7 @@
family_files = {}
+@deprecated('family_files[family_name] = file_path', since='20210305')
def register_family_file(family_name, file_path):
"""Register a single family class file.
@@ -399,11 +400,11 @@
def register_families_folder(folder_path):
"""Register all family class files contained in a directory."""
+ suffix = '_family.py'
for file_name in os.listdir(folder_path):
- if file_name.endswith('_family.py'):
- family_name = file_name[:-len('_family.py')]
- register_family_file(family_name, os.path.join(folder_path,
- file_name))
+ if file_name.endswith(suffix):
+ family_name = removesuffix(file_name, suffix)
+ family_files[family_name] = os.path.join(folder_path, file_name)
# Get the names of all known families, and initialize with empty dictionaries.
@@ -568,14 +569,14 @@
# Your private family path may be either an absolute or a relative path.
# You may have multiple paths defined in user_families_paths list.
#
-# You may also define various family files stored in the user_families
-# dict. Use the family name as dict key and the path or an url als value.
+# You may also define various family files stored directly in
+# family_files dict. Use the family name as dict key and the path or an
+# url as value.
#
# samples:
+# family_files['mywiki'] = 'https://de.wikipedia.org'
# user_families_paths = ['data/families']
-# user_families = {'mywiki': 'https://de.wikipedia.org'}
user_families_paths = [] # type: List[str]
-user_families = {} # type: dict
# ############# SOLVE_DISAMBIGUATION SETTINGS ############
#
@@ -1020,8 +1021,6 @@
# Setup custom family files
for file_path in user_families_paths:
register_families_folder(file_path)
-for name, path in user_families.items():
- register_family_file(name, path)
#
# When called as main program, list all configuration variables
#
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668698
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I91662836c735e85d545a4c5c221306cb9f81dd69
Gerrit-Change-Number: 668698
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668661 )
Change subject: [bugfix] Re-enable setting private family files
......................................................................
[bugfix] Re-enable setting private family files
- register_families_folder and register_family_file does not work with
Python 3 without globals() are passed to exec() function. Now use
user_families_paths list and user_families dict to reimplement
setting private family files. This has the advantage that
user-config.py does not need to have executable code, which is
shouldn't, see PAWS.
- usernames and disambiguation_comment are defaultdict instances.
It is not necessary to set their items to an empty dict which
would override user-config settings.
- revert generate_user_files.py documentation related to
register_famil??_* functions. More documentation is found in
EXTERNAL FAMILIES SETTINGS.
Bug: T270949
Change-Id: If0dd4eb47a5c13545c27b460bd1d05b5769f3262
---
M generate_user_files.py
M pywikibot/config2.py
2 files changed, 25 insertions(+), 38 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index 6e81771..a4140d9 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -175,34 +175,9 @@
# This is an automatically generated file. You can find more configuration
# parameters in 'config.py' file.
-# The family of sites to work on by default.
-#
-# ‘site.py’ imports ‘families/xxx_family.py’, so if you want to change
-# this variable, you need to use the name of one of the existing family files
-# in that folder or write your own, custom family file.
-#
-# For ‘site.py’ to be able to read your custom family file, you must
-# save it to ‘families/xxx_family.py’, where ‘xxx‘ is the codename of the
-# family that your custom ‘xxx_family.py’ family file defines.
-#
-# You can also save your custom family files to a different folder. As long
-# as you follow the ‘xxx_family.py’ naming convention, you can register your
-# custom folder in this configuration file with the following global function:
-#
-# register_families_folder(folder_path)
-#
-# Alternatively, you can register particular family files that do not need
-# to follow the ‘xxx_family.py’ naming convention using the following
-# global function:
-#
-# register_family_file(family_name, file_path)
-#
-# Where ‘family_name’ is the family code (the ‘xxx’ in standard family file
-# names) and ‘file_path’ is the absolute path to the target family file.
-#
-# If you use either of these functions to define the family to work on by
-# default (the ‘family’ variable below), you must place the function call
-# before the definition of the ‘family’ variable.
+# The family of sites we are working on. wikipedia.py will import
+# families/xxx_family.py so if you want to change this variable,
+# you need to write such a file.
family = '{main_family}'
# The language code of the site we're working on.
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 38f0300..91204be 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -14,13 +14,7 @@
PYWIKIBOT_NO_USER_CONFIG=2. If pywikibot is installed as a site-package
the behaviour is like PYWIKIBOT_NO_USER_CONFIG=2 is set.
-Provides two functions to register family classes which can be used in
-the user-config:
-
- - register_family_file
- - register_families_folder
-
-Other functions made available to user-config:
+Functions made available to user-config:
- user_home_path
@@ -32,7 +26,7 @@
- shortpath
"""
#
-# (C) Pywikibot team, 2003-2020
+# (C) Pywikibot team, 2003-2021
#
# Distributed under the terms of the MIT license.
#
@@ -400,8 +394,6 @@
Parameter file_path may be a path or an url.
family.AutoFamily function is used when the url is given.
"""
- usernames[family_name] = {}
- disambiguation_comment[family_name] = {}
family_files[family_name] = file_path
@@ -570,6 +562,21 @@
# user_script_paths = ['scripts.myscripts']
user_script_paths = [] # type: List[str]
+# ############# EXTERNAL FAMILIES SETTINGS ##############
+# Set your own family path to lookup for your family files.
+#
+# Your private family path may be either an absolute or a relative path.
+# You may have multiple paths defined in user_families_paths list.
+#
+# You may also define various family files stored in the user_families
+# dict. Use the family name as dict key and the path or an url als value.
+#
+# samples:
+# user_families_paths = ['data/families']
+# user_families = {'mywiki': 'https://de.wikipedia.org'}
+user_families_paths = [] # type: List[str]
+user_families = {} # type: dict
+
# ############# SOLVE_DISAMBIGUATION SETTINGS ############
#
# Set disambiguation_comment[FAMILY][LANG] to a non-empty string to override
@@ -1010,6 +1017,11 @@
" permission or set 'ignore_file_security_warnings' to true.")
sys.exit(1)
+# Setup custom family files
+for file_path in user_families_paths:
+ register_families_folder(file_path)
+for name, path in user_families.items():
+ register_family_file(name, path)
#
# When called as main program, list all configuration variables
#
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668661
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If0dd4eb47a5c13545c27b460bd1d05b5769f3262
Gerrit-Change-Number: 668661
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged