jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1306111?usp=email )
Change subject: config: Drop textfile_encoding variable and use 'utf-8'
directly instead
......................................................................
config: Drop textfile_encoding variable and use 'utf-8' directly instead
Bug: T430454
Change-Id: I5c51c9f6750432b7d7bb17998e944a66cf39960a
---
M pywikibot/config.py
M pywikibot/pagegenerators/_generators.py
M scripts/add_text.py
M scripts/interwiki.py
M scripts/listpages.py
M scripts/pagefromfile.py
M scripts/upload.py
7 files changed, 10 insertions(+), 15 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 47679c9..405a183 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -106,6 +106,7 @@
'absolute_import': '10.0.0 ',
'division': '10.0.0',
'unicode_literals': '10.0.0',
+ 'textfile_encoding': '11.5.0',
}
# ############# ACCOUNT SETTINGS ##############
@@ -497,12 +498,6 @@
transliteration_target: str | None = None
-# The encoding in which textfiles are stored, which contain lists of page
-# titles. The most used is 'utf-8'; 'utf-8-sig' recognizes BOM.
-# For a complete list please see:
-# https://docs.python.org/3/library/codecs.html#standard-encodings
-textfile_encoding = 'utf-8'
-
# currently terminal and buffer are the only supported userinterfaces
userinterface = 'terminal'
diff --git a/pywikibot/pagegenerators/_generators.py
b/pywikibot/pagegenerators/_generators.py
index c8224d0..a53d39c 100644
--- a/pywikibot/pagegenerators/_generators.py
+++ b/pywikibot/pagegenerators/_generators.py
@@ -20,7 +20,7 @@
from requests.exceptions import ReadTimeout
import pywikibot
-from pywikibot import config, date, xmlreader
+from pywikibot import date, xmlreader
from pywikibot.backports import batched
from pywikibot.comms import http
from pywikibot.exceptions import APIError, ServerError
@@ -477,7 +477,7 @@
site = pywikibot.Site()
# If source cannot be parsed as an HTTP URL, treat as local file
if not urlparse(source).netloc:
- with open(source, encoding=config.textfile_encoding) as local_file:
+ with open(source, encoding='utf-8') as local_file:
yield from _yield_titles(local_file, site)
# Else, fetch page (page should return text in same format as that expected
# in filename, i.e. pages separated by newlines or pages enclosed in double
diff --git a/scripts/add_text.py b/scripts/add_text.py
index c37ddbb..0642f27 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -74,7 +74,7 @@
from pathlib import Path
import pywikibot
-from pywikibot import config, pagegenerators, textlib
+from pywikibot import pagegenerators, textlib
from pywikibot.bot import AutomaticTWSummaryBot, ExistingPageBot
@@ -123,7 +123,7 @@
"""Read text to be added from file."""
if self.opt.textfile:
pth = Path(self.opt.textfile)
- self.opt.text = pth.read_text(encoding=config.textfile_encoding)
+ self.opt.text = pth.read_text(encoding='utf-8')
else:
# Translating the \\n into binary \n if given from command line
self.opt.text = self.opt.text.replace('\\n', '\n')
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index bbd5bfe..3258bbb 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -520,7 +520,7 @@
elif arg == 'hintfile':
hintfilename = value or pywikibot.input(
'Please enter the hint filename:')
- txt = Path(hintfilename).read_text(config.textfile_encoding)
+ txt = Path(hintfilename).read_text('utf-8')
self.hints.extend(m['title']
for m in pywikibot.link_regex.finditer(txt))
elif arg == 'untranslatedonly':
diff --git a/scripts/listpages.py b/scripts/listpages.py
index f8b4c2b..3706506 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -65,7 +65,7 @@
-encode [str] File encoding can be specified with ``-encode:name``
(name must be a valid python encoding: utf-8, etc.). If not
- specified, it defaults to :code:`config.textfile_encoding`.
+ specified, it defaults to ``utf-8``.
-put: [str] Save the list to the defined page of the wiki. By
default it does not overwrite an existing page.
@@ -188,7 +188,7 @@
'always': True,
'save': None,
'tofile': None,
- 'encode': config.textfile_encoding,
+ 'encode': 'utf-8',
'format': '1',
'notitle': False,
'outputlang': None,
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 519b932..ab99da3 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -242,7 +242,7 @@
pywikibot.info(f"\n\nReading '{self.filename}'...")
filepath = Path(self.filename)
try:
- text = filepath.read_text(encoding=config.textfile_encoding)
+ text = filepath.read_text(encoding='utf-8')
except OSError as e:
pywikibot.error(e)
return
diff --git a/scripts/upload.py b/scripts/upload.py
index 1d6dc3e..9f8a47c 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -191,7 +191,7 @@
return
description = filepath.read_text(
- encoding=pywikibot.config.textfile_encoding).replace('\r\n', '\n')
+ encoding='utf-8').replace('\r\n', '\n')
while not ('://' in url or os.path.exists(url)):
if not url:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1306111?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5c51c9f6750432b7d7bb17998e944a66cf39960a
Gerrit-Change-Number: 1306111
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]