jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862279 )
Change subject: [IMPR] use pathlib instead of codecs for replace.py
......................................................................
[IMPR] use pathlib instead of codecs for replace.py
- use pathlib.Path instead of codecs to open a file
- use readlines() instead of splitlines to read the file
- use f-strings instead of format()
Change-Id: I3095f2bac704344ea1fa850649e99b2fa0e7cdc0
---
M scripts/replace.py
1 file changed, 18 insertions(+), 7 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index d44ff14..9a3c511 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -146,10 +146,10 @@
#
# Distributed under the terms of the MIT license.
#
-import codecs
import re
from collections.abc import Sequence
from contextlib import suppress
+from pathlib import Path
from typing import Any, Optional
import pywikibot
@@ -807,7 +807,7 @@
return local_args, exceptions
-def handle_pairsfile(filename: str) -> List[str]:
+def handle_pairsfile(filename: str) -> Optional[List[str]]:
"""Handle -pairsfile argument.
.. versionadded:: 7.0
@@ -817,9 +817,8 @@
'Please enter the filename to read replacements from:')
try:
- with codecs.open(filename, 'r', 'utf-8') as f:
- # strip newlines, but not other characters
- replacements = f.read().splitlines()
+ with Path(filename).open(encoding='utf-8') as f:
+ replacements = f.readlines()
if not replacements:
raise OSError(f'{filename} is empty.')
except OSError as e:
@@ -828,8 +827,7 @@
if len(replacements) % 2:
pywikibot.error(
- '{} contains an incomplete pattern replacement pair.'.format(
- filename))
+ f'{filename} contains an incomplete pattern replacement pair.')
return None
# Strip BOM from first line
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862279
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: I3095f2bac704344ea1fa850649e99b2fa0e7cdc0
Gerrit-Change-Number: 862279
Gerrit-PatchSet: 1
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/+/863023 )
Change subject: [bugfix]: unquote title for red-links in Index"
......................................................................
[bugfix]: unquote title for red-links in Index"
When getting titles from Index page HTML code, characters
can be url-encoded (e.g. when an "'" is present in the title page).
Unquote to obtain the correct page title.
Change-Id: If1d6dfc0e411796df3d2b8ae1c673f76d99911ce
---
M pywikibot/proofreadpage.py
1 file changed, 16 insertions(+), 0 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 35ff2dd..56181aa 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -32,6 +32,7 @@
from functools import partial
from http import HTTPStatus
from typing import Any, Optional, Union
+from urllib.parse import unquote
from requests.exceptions import ReadTimeout
@@ -974,6 +975,7 @@
title = self._parse_redlink(href) # non-existing page
if title is None: # title not conforming to required format
continue
+ title = unquote(title)
else:
title = a_tag.get('title') # existing page
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/863023
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: If1d6dfc0e411796df3d2b8ae1c673f76d99911ce
Gerrit-Change-Number: 863023
Gerrit-PatchSet: 2
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(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/+/863230 )
Change subject: [bugfix] Timestripper find month with first letter uppercase or lowercase
......................................................................
[bugfix] Timestripper find month with first letter uppercase or lowercase
Bug: T324310
Change-Id: I79d9cc68a952f2d213aafe4987fc394226aa83ea
---
M pywikibot/textlib.py
1 file changed, 28 insertions(+), 8 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 7bee53a..8b252a8 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -25,7 +25,12 @@
from pywikibot.exceptions import InvalidTitleError, SiteDefinitionError
from pywikibot.family import Family
from pywikibot.time import TZoneFixedOffset
-from pywikibot.tools import ModuleDeprecationWrapper, deprecated
+from pywikibot.tools import (
+ ModuleDeprecationWrapper,
+ deprecated,
+ first_lower,
+ first_upper,
+)
from pywikibot.userinterfaces.transliteration import NON_LATIN_DIGITS
@@ -1836,13 +1841,18 @@
self.site = pywikibot.Site() if site is None else site
self.origNames2monthNum = {}
- for n, (_long, _short) in enumerate(self.site.months_names, start=1):
- self.origNames2monthNum[_long] = n
- self.origNames2monthNum[_short] = n
- # in some cases month in ~~~~ might end without dot even if
- # site.months_names do not.
- if _short.endswith('.'):
- self.origNames2monthNum[_short[:-1]] = n
+ # use first_lower/first_upper for 'vi' language because monthsnames
+ # were changed: T324310
+ functions = [first_upper,
+ first_lower] if self.site.lang == 'vi' else [str]
+ for n, (long, short) in enumerate(self.site.months_names, start=1):
+ for func in functions:
+ self.origNames2monthNum[func(long)] = n
+ self.origNames2monthNum[func(short)] = n
+ # in some cases month in ~~~~ might end without dot even if
+ # site.months_names do not.
+ if short.endswith('.'):
+ self.origNames2monthNum[func(short[:-1])] = n
self.groups = ['year', 'month', 'hour', 'time', 'day', 'minute',
'tzinfo']
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/863230
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: I79d9cc68a952f2d213aafe4987fc394226aa83ea
Gerrit-Change-Number: 863230
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862284 )
Change subject: [doc] Update ROADMAP.rst and CHANGELOG.rst
......................................................................
[doc] Update ROADMAP.rst and CHANGELOG.rst
Change-Id: I6f54459dc57afb9bd994bcc40c758ed62852c159
---
M ROADMAP.rst
M scripts/CHANGELOG.rst
2 files changed, 23 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index d478166..7a3b1ae 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,15 @@
Current release 8.0.0
---------------------
+* Let user the choice which section to be copied with :mod:`generate_user_files
+ <pywikibot.scripts.generate_user_files>` (:phab:`T145372`)
+* use :func:`roundrobin_generators<tools.itertools.roundrobin_generators>` to combine generators
+ when limit option is given
+* Ignore OSError if API cache cannot be written
+* Update tools._unidata._category_cf from Unicodedata version 15.0.0
+* :meth:`Timestamp.set_timestamp()<pywikibot.time.Timestamp.set_timestamp>` raises TypeError
+ instead of ValueError if conversion fails
+* Python 3.12 is supported
* All parameters of :meth:`Category.members()<page.Category.members>`,
:meth:`Category.subcategories()<page.Category.subcategories>` and
:meth:`Category.articles()<page.Category.articles>` are keyword only
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 5ff4b7d..0119e56 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -14,6 +14,11 @@
* Enable pagegenerators options with ``move`` and ``remove`` actions (:phab:`T318239`)
+clean_sandbox
+~~~~~~~~~~~~~
+
+* A `-textfile` option was addet to fetch the text from a file
+
create_isbn_edition
~~~~~~~~~~~~~~~~~~~
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862284
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: I6f54459dc57afb9bd994bcc40c758ed62852c159
Gerrit-Change-Number: 862284
Gerrit-PatchSet: 1
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/+/862225 )
Change subject: [doc] Fix docstring in maintenance/cache.py
......................................................................
[doc] Fix docstring in maintenance/cache.py
Change-Id: I2220879df7906b6c27eea792efe676337f970117
---
M scripts/maintenance/cache.py
1 file changed, 20 insertions(+), 15 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/cache.py b/scripts/maintenance/cache.py
index 2340fab..9ae4129 100755
--- a/scripts/maintenance/cache.py
+++ b/scripts/maintenance/cache.py
@@ -74,6 +74,7 @@
import pickle
import sys
from pathlib import Path
+from typing import Optional
import pywikibot
from pywikibot.data import api
@@ -217,23 +218,18 @@
self._cachefile_path().unlink()
-def process_entries(cache_path, func, use_accesstime=None, output_func=None,
- action_func=None):
- """
- Check the contents of the cache.
+def process_entries(cache_path, func, use_accesstime: Optional[bool] = None,
+ output_func=None, action_func=None):
+ """Check the contents of the cache.
- This program tries to use file access times to determine
- whether cache files are being used.
- However file access times are not always usable.
- On many modern filesystems, they have been disabled.
- On Unix, check the filesystem mount options. You may
- need to remount with 'strictatime'.
+ This program tries to use file access times to determine whether
+ cache files are being used. However file access times are not always
+ usable. On many modern filesystems, they have been disabled. On Unix,
+ check the filesystem mount options. You may need to remount with
+ 'strictatime'.
- :param use_accesstime: Whether access times should be used.
- :type use_accesstime: bool tristate:
- - None = detect
- - False = don't use
- - True = always use
+ :param use_accesstime: Whether access times should be used. `None`
+ for detect, `False` for don't use and `True` for always use.
"""
if not cache_path:
cache_path = os.path.join(pywikibot.config.base_dir,
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/862225
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: I2220879df7906b6c27eea792efe676337f970117
Gerrit-Change-Number: 862225
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