jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675761 )
Change subject: Revert "[cleanup] remove interwiki config settings"
......................................................................
Revert "[cleanup] remove interwiki config settings"
This reverts commit c455d2230eec9d7684e00f86dbdbfe93cffe7b60.
Bug: T278675
Change-Id: Id774c8a41fb848a0a0ec4500485cf6460818605f
---
M pywikibot/config2.py
M pywikibot/cosmetic_changes.py
M tests/generate_user_files_tests.py
3 files changed, 50 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index f514ce1..7e1680c 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -113,12 +113,10 @@
'copyright_max_query_for_page', 'copyright_msn', 'copyright_show_date',
'copyright_show_length', 'copyright_skip_query', 'copyright_yahoo',
'db_hostname', 'deIndentTables', 'fake_user_agent', 'flickr',
- 'interwiki_contents_on_disk', 'interwiki_backlink', 'interwiki_graph',
- 'interwiki_graph_formats', 'interwiki_graph_url', 'interwiki_min_subjects',
- 'interwiki_shownew', 'line_separator', 'LS', 'msn_appid', 'panoramio',
- 'persistent_http', 'proxy', 'special_page_limit', 'splitLongParagraphs',
- 'sysopnames', 'use_mwparserfromhell', 'use_SSL_onlogin', 'use_SSL_always',
- 'without_interwiki', 'yahoo_appid',
+ 'interwiki_contents_on_disk', 'line_separator', 'LS', 'msn_appid',
+ 'panoramio', 'persistent_http', 'proxy', 'special_page_limit',
+ 'splitLongParagraphs', 'sysopnames', 'use_mwparserfromhell',
+ 'use_SSL_onlogin', 'use_SSL_always', 'yahoo_appid',
}
_future_variables = {'absolute_import', 'division', 'unicode_literals'}
@@ -606,6 +604,49 @@
# user_families_paths = ['data/families']
user_families_paths = [] # type: List[str]
+# ############# INTERWIKI SETTINGS ##############
+
+# Should interwiki.py report warnings for missing links between foreign
+# languages?
+interwiki_backlink = True
+
+# Should interwiki.py display every new link it discovers?
+interwiki_shownew = True
+
+# Should interwiki.py output a graph PNG file on conflicts?
+# You need pydot for this:
+# https://pypi.org/project/pydot/
+interwiki_graph = False
+
+# Specifies that the robot should process that amount of subjects at a time,
+# only starting to load new pages in the original language when the total
+# falls below that number. Default is to process (at least) 100 subjects at
+# once.
+interwiki_min_subjects = 100
+
+# If interwiki graphs are enabled, which format(s) should be used?
+# Supported formats include png, jpg, ps, and svg. See:
+# http://www.graphviz.org/doc/info/output.html
+# If you want to also dump the dot files, you can use this in your
+# user-config.py:
+# interwiki_graph_formats = ['dot', 'png']
+# If you need a PNG image with an HTML image map, use this:
+# interwiki_graph_formats = ['png', 'cmap']
+# If you only need SVG images, use:
+# interwiki_graph_formats = ['svg']
+interwiki_graph_formats = ['png']
+
+# You can post the contents of your autonomous_problems.dat to the wiki,
+# e.g. to https://de.wikipedia.org/wiki/Wikipedia:Interwiki-Konflikte .
+# This allows others to assist you in resolving interwiki problems.
+# To help these people, you can upload the interwiki graphs to your
+# webspace somewhere. Set the base URL here, e.g.:
+# 'https://www.example.org/~yourname/interwiki-graphs/'
+interwiki_graph_url = None
+
+# Save file with local articles without interwikis.
+without_interwiki = False
+
# ############# SOLVE_DISAMBIGUATION SETTINGS ############
#
# Set disambiguation_comment[FAMILY][LANG] to a non-empty string to override
@@ -707,7 +748,7 @@
# ############# COSMETIC CHANGES SETTINGS ##############
# The bot can make some additional changes to each page it edits, e.g. fix
-# whitespace or positioning category links.
+# whitespace or positioning of category links.
# This is an experimental feature; handle with care and consider re-checking
# each bot edit if enabling this!
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 8ef0bfd..f6f0929 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -79,6 +79,7 @@
# Subpage templates. Must be in lower case,
# whereas subpage itself must be case sensitive
+# This is also used by interwiki.py
# TODO: Maybe move it to family file and implement global instances
moved_links = {
'ar': (['documentation', 'template documentation', 'شرح', 'توثيق'],
diff --git a/tests/generate_user_files_tests.py b/tests/generate_user_files_tests.py
index 69490d7..9cf64d3 100644
--- a/tests/generate_user_files_tests.py
+++ b/tests/generate_user_files_tests.py
@@ -91,6 +91,7 @@
self.assertIsNotNone(config_text)
for section in ('LOGFILE SETTINGS',
'EXTERNAL SCRIPT PATH SETTINGS',
+ 'INTERWIKI SETTINGS',
'FURTHER SETTINGS',
'HTTP SETTINGS',
'REPLICATION BOT SETTINGS',
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675761
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: Id774c8a41fb848a0a0ec4500485cf6460818605f
Gerrit-Change-Number: 675761
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/+/675345 )
Change subject: [FIX] Allow deleting any subclass of BasePage by title
......................................................................
[FIX] Allow deleting any subclass of BasePage by title
Also replace deprecated parameters
Bug: T278659
Change-Id: If587e793ddeeda6ffba07946f481c8220b96c357
---
M pywikibot/site/_apisite.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index fc63470..1756a15 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2058,7 +2058,7 @@
Page to be deleted can be given either as Page object or as pageid.
@param page: Page to be deleted or its pageid.
- @type page: Page or, in case of pageid, int or str
+ @type page: L{pywikibot.page.BasePage} or, for pageid, int or str
@param reason: Deletion reason.
@raises TypeError, ValueError: page has wrong type/value.
@@ -2066,9 +2066,9 @@
token = self.tokens['delete']
params = {'action': 'delete', 'token': token, 'reason': reason}
- if isinstance(page, pywikibot.Page):
+ if isinstance(page, pywikibot.page.BasePage):
params['title'] = page
- msg = page.title(withSection=False)
+ msg = page.title(with_section=False)
else:
pageid = int(page)
params['pageid'] = pageid
@@ -2116,7 +2116,7 @@
if isinstance(page, pywikibot.Page):
params['title'] = page
- msg = page.title(withSection=False)
+ msg = page.title(with_section=False)
else:
pageid = int(page)
params['pageid'] = pageid
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675345
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: If587e793ddeeda6ffba07946f481c8220b96c357
Gerrit-Change-Number: 675345
Gerrit-PatchSet: 1
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(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/+/675182 )
Change subject: [IMPR] decrease nested flow statements in textlib.replaceLanguageLinks
......................................................................
[IMPR] decrease nested flow statements in textlib.replaceLanguageLinks
Change-Id: I530a6dffc7a11287815a99f78671bd80449b0e3b
---
M pywikibot/textlib.py
1 file changed, 54 insertions(+), 56 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ed2d1af..c7e7fb6 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1087,63 +1087,61 @@
s2 = removeLanguageLinksAndSeparator(oldtext, site=site, marker=marker,
separator=separatorstripped)
s = interwikiFormat(new, insite=site)
- if s:
- 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
- else separator) + s2.replace(marker, '').strip()
- else:
- # calculate what was after the language links on the page
- firstafter = s2.find(marker)
- if firstafter < 0:
- firstafter = len(s2)
- else:
- firstafter += len(marker)
- # Any text in 'after' part that means we should keep it after?
- if '</noinclude>' in s2[firstafter:]:
- if separatorstripped:
- s = separator + s
- newtext = (s2[:firstafter].replace(marker, '')
- + s + s2[firstafter:])
- elif site.code in site.family.categories_last:
- cats = getCategoryLinks(s2, site=site)
- s2 = removeCategoryLinksAndSeparator(
- s2.replace(marker, cseparatorstripped).strip(), site) \
- + separator + s
- newtext = replaceCategoryLinks(s2, cats, site=site,
- addOnly=True)
- # for Wikitravel's language links position.
- # (not supported by rewrite - no API)
- elif site.family.name == 'wikitravel':
- s = separator + s + separator
- newtext = (s2[:firstafter].replace(marker, '')
- + s + s2[firstafter:])
- else:
- if template or template_subpage:
- if template_subpage:
- includeOn = '<includeonly>'
- includeOff = '</includeonly>'
- else:
- includeOn = '<noinclude>'
- includeOff = '</noinclude>'
- separator = ''
- # Do we have a noinclude at the end of the template?
- parts = s2.split(includeOff)
- lastpart = parts[-1]
- if re.match(r'\s*%s' % marker, lastpart):
- # Put the langlinks back into the noinclude's
- regexp = re.compile(r'%s\s*%s' % (includeOff, marker))
- newtext = regexp.sub(s + includeOff, s2)
- else:
- # Put the langlinks at the end, inside noinclude's
- newtext = (s2.replace(marker, '').strip()
- + separator
- + '%s\n%s%s\n' % (includeOn, s, includeOff))
- else:
- newtext = s2.replace(marker, '').strip() + separator + s
- else:
+ if not s:
newtext = s2.replace(marker, '')
+ elif 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
+ else separator) + s2.replace(marker, '').strip()
+ else:
+ # calculate what was after the language links on the page
+ firstafter = s2.find(marker)
+ if firstafter < 0:
+ firstafter = len(s2)
+ else:
+ firstafter += len(marker)
+
+ # Any text in 'after' part that means we should keep it after?
+ if '</noinclude>' in s2[firstafter:]:
+ if separatorstripped:
+ s = separator + s
+ newtext = (s2[:firstafter].replace(marker, '')
+ + s + s2[firstafter:])
+ elif site.code in site.family.categories_last:
+ cats = getCategoryLinks(s2, site=site)
+ s2 = removeCategoryLinksAndSeparator(
+ s2.replace(marker, cseparatorstripped).strip(), site) \
+ + separator + s
+ newtext = replaceCategoryLinks(s2, cats, site=site, addOnly=True)
+ # for Wikitravel's language links position.
+ # (not supported by rewrite - no API)
+ elif site.family.name == 'wikitravel':
+ s = separator + s + separator
+ newtext = (s2[:firstafter].replace(marker, '')
+ + s + s2[firstafter:])
+ elif template or template_subpage:
+ if template_subpage:
+ includeOn = '<includeonly>'
+ includeOff = '</includeonly>'
+ else:
+ includeOn = '<noinclude>'
+ includeOff = '</noinclude>'
+ separator = ''
+ # Do we have a noinclude at the end of the template?
+ parts = s2.split(includeOff)
+ lastpart = parts[-1]
+ if re.match(r'\s*%s' % marker, lastpart):
+ # Put the langlinks back into the noinclude's
+ regexp = re.compile(r'{}\s*{}'.formar(includeOff, marker))
+ newtext = regexp.sub(s + includeOff, s2)
+ else:
+ # Put the langlinks at the end, inside noinclude's
+ newtext = (s2.replace(marker, '').strip()
+ + separator
+ + '{}\n{}{}\n'.format(includeOn, s, includeOff))
+ else:
+ newtext = s2.replace(marker, '').strip() + separator + s
# special parts above interwiki
above_interwiki = []
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675182
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: I530a6dffc7a11287815a99f78671bd80449b0e3b
Gerrit-Change-Number: 675182
Gerrit-PatchSet: 3
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/+/675169 )
Change subject: [tests] Don't import standard library parts from tests
......................................................................
[tests] Don't import standard library parts from tests
add funktions to __all__ which are and should only be imported;
requests, unittest, mock, patch should imported directly instead
Change-Id: I030a2c97ba1ba0c28c2dbfc4166af76b16e89a9c
---
M tests/__init__.py
1 file changed, 8 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/__init__.py b/tests/__init__.py
index cb700bb..db64b70 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -5,8 +5,11 @@
# Distributed under the terms of the MIT license.
#
__all__ = (
- 'requests', 'unittest', 'TestRequest', 'patch_request', 'unpatch_request',
- 'mock', 'Mock', 'MagicMock', 'patch')
+ 'create_path_func', 'join_cache_path', 'join_data_path',
+ 'join_html_data_path', 'join_images_path', 'join_pages_path',
+ 'join_root_path', 'join_xml_data_path', 'patch_request', 'unittest_print',
+ 'unpatch_request',
+)
import functools
import os
@@ -15,14 +18,14 @@
from contextlib import suppress
from itertools import chain
-from unittest import mock
-from unittest.mock import MagicMock, Mock, patch
+from unittest import mock # noqa: F401
+from unittest.mock import MagicMock, Mock, patch # noqa: F401
# Verify that the unit tests have a base working environment:
# - requests is mandatory
# however if unavailable this will fail on use; see pywikibot/tools.py
# - mwparserfromhell is optional, so is only imported in textlib_tests
-import requests
+import requests # noqa: F401
import pywikibot.data.api
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675169
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: I030a2c97ba1ba0c28c2dbfc4166af76b16e89a9c
Gerrit-Change-Number: 675169
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged