Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
Change-Id: I83e1efacfc0076341cc6b3754ce4f01c4f635cef
  • Loading branch information
xqt committed Nov 11, 2023
2 parents f993bad + ade985b commit 7fb0ef0
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 62 deletions.
4 changes: 4 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ environment:
PYTHON_VERSION: "3.11.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python312"
PYTHON_VERSION: "3.12.x"
PYTHON_ARCH: "32"

matrix:
fast_finish: false

Expand Down
19 changes: 19 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
Release history
===============

8.5.0
-----
*05. November 2023*

* Add a pagegenerators filter option to check if a page is redirect (:phab:`T261549`)
* Add support for ``vikidia:nl`` site
* Replace MediaWiki API deprecated ``inprop=preload`` with ``preloadcontent`` (:phab:`T348910`)
* Remove check for purge right from APISite.purgepages (:phab:`T349348`)
* Add MediaInfo editLabels, AddClaim and removeClaim functions (:phab:`T348422`)
* Drop unused ``Family.use_hard_category_redirects`` (:phab:`T348953`)
* No longer drop site decorators for optimized codes (:phab:`T74424`)
* Improve handling of uninitialized MediaInfo
* Add support for ``vikidia:ar`` site
* Make exception about missing mediainfo more friendly
* L10N and i18n updates
* Give visible error to user when there are no rights (:phab:`T345342`)


8.4.0
-----
*07. October 2023*
Expand Down
15 changes: 2 additions & 13 deletions ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
Current release
---------------

* Add a pagegenerators filter option to check if a page is redirect (:phab:`T261549`)
* Add support for ``vikidia:nl`` site
* Replace MediaWiki API deprecated ``inprop=preload`` with ``preloadcontent`` (:phab:`T348910`)
* Remove check for purge right from APISite.purgepages (:phab:`T349348`)
* Add MediaInfo editLabels, AddClaim and removeClaim functions (:phab:`T348422`)
* Drop unused ``Family.use_hard_category_redirects`` (:phab:`T348953`)
* No longer drop site decorators for optimized codes (:phab:`T74424`)
* Improve handling of uninitialized MediaInfo
* Add support for ``vikidia:ar`` site
* Make exception about missing mediainfo more friendly
* L10N and i18n updates
* Give visible error to user when there are no rights (:phab:`T345342`)
* **Python 3.6 support will be discontinued** and this is the last version supporting it.
* Add support for new wikis (:phab:`T350231`, :phab:`T350237`, :phab:`T350243`, :phab:`T350375`)
* **Python 3.6 support will be discontinued soon**.


Deprecations
Expand Down
2 changes: 1 addition & 1 deletion pywikibot/__metadata__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


__name__ = 'pywikibot'
__version__ = '8.5.0'
__version__ = '8.5.1'
__description__ = 'Python MediaWiki Bot Framework'
__maintainer__ = 'The Pywikibot team'
__maintainer_email__ = '[email protected]'
Expand Down
27 changes: 16 additions & 11 deletions pywikibot/data/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# Distributed under the terms of the MIT license.
#
from textwrap import fill
from typing import Optional
from urllib.parse import quote

Expand Down Expand Up @@ -135,10 +136,14 @@ def select(self,
return result

def query(self, query: str, headers: Optional[Dict[str, str]] = None):
"""
Run SPARQL query and return parsed JSON result.
"""Run SPARQL query and return parsed JSON result.
.. versionchanged:: 8.5
:exc:``exceptions.NoUsernameError` is raised if the response
looks like the user is not logged in.
:param query: Query text
:raises NoUsernameError: User not logged in
"""
if headers is None:
headers = DEFAULT_HEADERS
Expand All @@ -165,15 +170,15 @@ def query(self, query: str, headers: Optional[Dict[str, str]] = None):
# not in case the response otherwise might have it in between
strcontent = self.last_response.content.decode()
if (strcontent.startswith('<!DOCTYPE html>')
and 'https://commons-query.wikimedia.org' in url):
if ('Special:UserLogin' in strcontent
or 'Special:OAuth' in strcontent):
message = ('You need to log in to Wikimedia Commons '
'and give OAUTH permission. '
'Open https://commons-query.wikimedia.org '
'with browser to login and give permission.')
raise NoUsernameError('User not logged in. ' + message)

and 'https://commons-query.wikimedia.org' in url
and ('Special:UserLogin' in strcontent
or 'Special:OAuth' in strcontent)):
raise NoUsernameError(fill(
'User not logged in. You need to log in to Wikimedia '
'Commons and give OAUTH permission. Open '
'https://commons-query.wikimedia.org with browser to '
'login and give permission.'
))
return None

def ask(self, query: str,
Expand Down
40 changes: 20 additions & 20 deletions pywikibot/families/wikipedia_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
'ja', 'zh', 'uk', 'vi', 'war', 'ar', 'pt', 'fa', 'ca', 'sr', 'id',
'ko', 'no', 'ce', 'fi', 'tr', 'cs', 'hu', 'tt', 'sh', 'ro',
'zh-min-nan', 'eu', 'ms', 'eo', 'he', 'hy', 'da', 'bg', 'cy', 'sk',
'uz', 'azb', 'simple', 'et', 'be', 'kk', 'min', 'el', 'hr', 'lt', 'gl',
'ur', 'az', 'sl', 'lld', 'ka', 'nn', 'th', 'hi', 'ta', 'bn', 'mk',
'uz', 'azb', 'simple', 'et', 'be', 'kk', 'el', 'min', 'hr', 'lt', 'gl',
'ur', 'az', 'sl', 'lld', 'ka', 'nn', 'hi', 'th', 'ta', 'bn', 'mk',
'la', 'zh-yue', 'ast', 'lv', 'af', 'tg', 'my', 'mg', 'sq', 'mr', 'bs',
'oc', 'te', 'ml', 'be-tarask', 'br', 'nds', 'ky', 'sw', 'lmo', 'jv',
'new', 'pnb', 'vec', 'ht', 'pms', 'ba', 'ku', 'lb', 'su', 'ga', 'is',
'szl', 'fy', 'ckb', 'cv', 'pa', 'tl', 'an', 'wuu', 'diq', 'io', 'sco',
'vo', 'yo', 'ne', 'ha', 'kn', 'ia', 'gu', 'als', 'avk', 'crh', 'bar',
'oc', 'te', 'ml', 'br', 'be-tarask', 'nds', 'ky', 'sw', 'lmo', 'jv',
'new', 'pnb', 'vec', 'ht', 'pms', 'ku', 'ba', 'lb', 'su', 'ga', 'is',
'szl', 'fy', 'ckb', 'cv', 'pa', 'tl', 'an', 'wuu', 'diq', 'io', 'vo',
'sco', 'yo', 'ha', 'ne', 'kn', 'ia', 'gu', 'als', 'avk', 'crh', 'bar',
'scn', 'bpy', 'qu', 'mn', 'nv', 'ig', 'ban', 'xmf', 'si', 'frr', 'tum',
'ps', 'mzn', 'os', 'or', 'bat-smg', 'sah', 'cdo', 'gd', 'bug', 'bcl',
'sd', 'yi', 'ilo', 'am', 'li', 'nap', 'gor', 'fo', 'hsb', 'map-bms',
'mai', 'shn', 'eml', 'ace', 'zh-classical', 'as', 'sa', 'wa', 'ie',
'mzn', 'ps', 'os', 'or', 'bat-smg', 'sah', 'cdo', 'gd', 'bug', 'bcl',
'sd', 'yi', 'ilo', 'am', 'li', 'nap', 'gor', 'fo', 'hsb', 'mai',
'map-bms', 'shn', 'eml', 'ace', 'zh-classical', 'as', 'sa', 'wa', 'ie',
'hyw', 'sn', 'mhr', 'lij', 'zu', 'hif', 'bjn', 'mrj', 'km', 'mni',
'hak', 'sat', 'roa-tara', 'pam', 'rue', 'bh', 'nso', 'ary', 'dag',
'so', 'mi', 'myv', 'nds-nl', 'se', 'vls', 'co', 'sc', 'bo', 'kw',
'vep', 'glk', 'tk', 'kab', 'gan', 'rw', 'fiu-vro', 'gv', 'ab', 'zea',
'so', 'mi', 'nds-nl', 'myv', 'se', 'co', 'vls', 'sc', 'bo', 'vep',
'kw', 'glk', 'tk', 'kab', 'gan', 'rw', 'fiu-vro', 'gv', 'ab', 'zea',
'ug', 'nah', 'skr', 'mt', 'frp', 'tly', 'udm', 'pcd', 'kv', 'gn',
'csb', 'smn', 'ay', 'nrm', 'ks', 'lez', 'olo', 'mwl', 'lfn', 'mdf',
'lo', 'stq', 'ang', 'kaa', 'fur', 'rm', 'lad', 'ext', 'gom', 'pap',
'tw', 'tyv', 'koi', 'av', 'dsb', 'ln', 'dty', 'cbk-zam', 'dv', 'ksh',
'za', 'gag', 'lg', 'bxr', 'pfl', 'szy', 'blk', 'tay', 'pag', 'pi',
'stq', 'ang', 'kaa', 'lo', 'fur', 'rm', 'lad', 'ext', 'gom', 'pap',
'tw', 'tyv', 'koi', 'av', 'ln', 'dsb', 'dty', 'cbk-zam', 'dv', 'ksh',
'za', 'lg', 'gag', 'bxr', 'pfl', 'szy', 'blk', 'tay', 'pag', 'pi',
'haw', 'awa', 'inh', 'krc', 'xal', 'pdc', 'to', 'atj', 'tcy', 'arc',
'mnw', 'shi', 'jam', 'kbp', 'wo', 'ff', 'nia', 'anp', 'kbd', 'om',
'nov', 'xh', 'ki', 'nqo', 'bi', 'tpi', 'tet', 'roa-rup', 'jbo', 'tn',
'mnw', 'shi', 'jam', 'kbp', 'wo', 'ff', 'nia', 'anp', 'xh', 'om',
'kbd', 'nov', 'ki', 'nqo', 'bi', 'tpi', 'tet', 'roa-rup', 'jbo', 'tn',
'fj', 'kg', 'lbe', 'guw', 'ty', 'cu', 'rmy', 'trv', 'ami', 'srn',
'mad', 'sm', 'alt', 'ltg', 'gcr', 'chr', 'ny', 'pcm', 'st', 'pih',
'gpe', 'got', 'ss', 'gur', 'ee', 'kcg', 'bm', 'ts', 've', 'chy', 'rn',
'ch', 'ady', 'ik', 'fon', 'guc', 'fat', 'pnt', 'iu', 'pwn', 'sg',
'din', 'ti', 'kl', 'dz', 'cr',
'mad', 'alt', 'sm', 'ltg', 'gcr', 'chr', 'ny', 'pcm', 'st', 'zgh',
'pih', 'gpe', 'got', 'ss', 'dga', 'kcg', 'gur', 'ee', 'bm', 'ts', 've',
'bbc', 'chy', 'rn', 'ch', 'ady', 'ik', 'fon', 'guc', 'fat', 'pnt',
'iu', 'pwn', 'sg', 'din', 'ti', 'kl', 'dz', 'cr',
]

# Sites we want to edit but not count as real languages
Expand Down
6 changes: 3 additions & 3 deletions pywikibot/families/wikiquote_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
'es', 'tr', 'eo', 'sk', 'az', 'bs', 'ca', 'zh', 'sr', 'fi', 'lt', 'sl',
'ar', 'id', 'su', 'bg', 'hy', 'hr', 'el', 'nn', 'sv', 'li', 'hu', 'ko',
'sah', 'nl', 'ja', 'la', 'ta', 'ig', 'hi', 'as', 'gl', 'gu', 'ur',
'tl', 'guw', 'be', 'te', 'vi', 'bn', 'cy', 'no', 'sq', 'ml', 'kn',
'eu', 'ro', 'ku', 'uz', 'ka', 'da', 'sa', 'is', 'th', 'bcl', 'br',
'mr', 'af', 'ky',
'bjn', 'tl', 'guw', 'be', 'te', 'vi', 'bn', 'cy', 'no', 'sq', 'ml',
'kn', 'eu', 'ro', 'ku', 'uz', 'ka', 'da', 'sa', 'is', 'th', 'bcl',
'br', 'mr', 'af', 'ky',
]

category_redirect_templates = {
Expand Down
6 changes: 3 additions & 3 deletions pywikibot/families/wikisource_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):

languages_by_size = [
'pl', 'en', 'ru', 'de', 'fr', 'zh', 'he', 'uk', 'it', 'ar', 'es',
'mul', 'gu', 'cs', 'sr', 'pt', 'bn', 'sv', 'fa', 'ko', 'hu', 'ta',
'ml', 'sa', 'te', 'tr', 'sl', 'be', 'vi', 'la', 'hy', 'nl', 'el', 'ja',
'ro', 'fi', 'nap', 'az', 'ca', 'hr', 'br', 'no', 'id', 'kn', 'th',
'mul', 'gu', 'cs', 'sr', 'pt', 'bn', 'sv', 'fa', 'ko', 'ta', 'hu',
'ml', 'sa', 'te', 'tr', 'be', 'sl', 'la', 'vi', 'hy', 'nl', 'el', 'ja',
'ro', 'fi', 'nap', 'az', 'ca', 'hr', 'br', 'id', 'no', 'kn', 'th',
'hi', 'cy', 'vec', 'eo', 'is', 'mr', 'ban', 'pms', 'lij', 'da', 'et',
'as', 'mk', 'yi', 'bg', 'jv', 'wa', 'li', 'lt', 'pa', 'or', 'eu', 'gl',
'bs', 'sah', 'sk', 'su', 'zh-min-nan', 'fo',
Expand Down
2 changes: 1 addition & 1 deletion pywikibot/families/wiktionary_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
'ur', 'cy', 'ps', 'tg', 'kbd', 'he', 'vo', 'om', 'sl', 'af',
'zh-min-nan', 'ms', 'scn', 'tl', 'pa', 'fy', 'sw', 'kk', 'ka', 'nn',
'min', 'lv', 'nds', 'gor', 'sq', 'lb', 'bs', 'co', 'mn', 'pnb', 'nah',
'yue', 'ckb', 'sa', 'km', 'diq', 'be', 'vec', 'nia', 'tk', 'mk', 'sm',
'yue', 'ckb', 'sa', 'diq', 'km', 'be', 'vec', 'nia', 'tk', 'mk', 'sm',
'hsb', 'ks', 'shy', 'bcl', 'su', 'ga', 'btm', 'gd', 'an', 'gom', 'mr',
'ha', 'wo', 'mni', 'ia', 'bjn', 'ang', 'mt', 'tt', 'sd', 'blk', 'fo',
'so', 'si', 'gn', 'ie', 'mi', 'csb', 'ug', 'guw', 'st', 'hif', 'jbo',
Expand Down
22 changes: 14 additions & 8 deletions pywikibot/page/_wikibase.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class WikibaseEntity:

DATA_ATTRIBUTES: Dict[str, Any] = {}

def __init__(self, repo, id_=None) -> None:
def __init__(self, repo, id_: Optional[str] = None) -> None:
"""
Initializer.
Expand Down Expand Up @@ -141,14 +141,14 @@ def _initialize_empty(self):
for key, cls in self.DATA_ATTRIBUTES.items():
setattr(self, key, cls.new_empty(self.repo))

def _defined_by(self, singular: bool = False) -> dict:
def _defined_by(self, singular: bool = False) -> Dict[str, str]:
"""
Internal function to provide the API parameters to identify the entity.
An empty dict is returned if the entity has not been created yet.
:param singular: Whether the parameter names should use the singular
form
form
:return: API parameters
"""
params = {}
Expand All @@ -159,7 +159,7 @@ def _defined_by(self, singular: bool = False) -> dict:
params['ids'] = self.id
return params

def getID(self, numeric: bool = False):
def getID(self, numeric: bool = False) -> Union[int, str]:
"""
Get the identifier of this entity.
Expand Down Expand Up @@ -406,6 +406,8 @@ def _defined_by(self, singular: bool = False) -> dict:
"""
Internal function to provide the API parameters to identify the entity.
.. versionadded:: 8.5
:param singular: Whether the parameter names should use the singular
form
:raise NoWikibaseEntityError: if this entity is associated with
Expand Down Expand Up @@ -500,13 +502,16 @@ def editLabels(self, labels: LANGUAGE_TYPE, **kwargs) -> None:
>>> page = pywikibot.FilePage(repo, 'File:Sandbox-Test.svg')
>>> item = page.data_item()
>>> item.editLabels({'en': 'Test file.'}) # doctest: +SKIP
.. versionadded:: 8.5
"""
data = {'labels': labels}
self.editEntity(data, **kwargs)

def addClaim(self, claim, bot: bool = True, **kwargs):
"""
Add a claim to the MediaInfo.
"""Add a claim to the MediaInfo.
.. versionadded:: 8.5
:param claim: The claim to add
:type claim: pywikibot.page.Claim
Expand All @@ -525,8 +530,9 @@ def addClaim(self, claim, bot: bool = True, **kwargs):
claim.on_item = self

def removeClaims(self, claims, **kwargs) -> None:
"""
Remove the claims from the MediaInfo.
"""Remove the claims from the MediaInfo.
.. versionadded:: 8.5
:param claims: list of claims to be removed
:type claims: list or pywikibot.Claim
Expand Down
5 changes: 4 additions & 1 deletion pywikibot/pagegenerators/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,10 @@ def _handle_logevents(self, value: str) -> HANDLER_RETURN_TYPE:
return self._parse_log_events(*params)

def _handle_redirect(self, value: str) -> HANDLER_RETURN_TYPE:
"""Handle `-redirect` argument."""
"""Handle `-redirect` argument.
.. versionadded:: 8.5
"""
if not value:
# True by default
value = 'true'
Expand Down
2 changes: 1 addition & 1 deletion scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
#
# Distributed under the terms of the MIT license.
#
__version__ = '8.5.0'
__version__ = '8.6.0'

0 comments on commit 7fb0ef0

Please sign in to comment.