jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511919 )
Change subject: [bugfix] color_format needs indexed replacement fields in Python 2
......................................................................
[bugfix] color_format needs indexed replacement fields in Python 2
pywikibot.tools.formatter.color_format needs indexed replacement fields
in Python 2 even Python 2.7 does not need indexed fields for str.format().
Bug: T224140
Change-Id: Id848d585655ba6c7427789619e55dc2b7bfb8a83
---
M pwb.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index cd0324a..44f95da 100755
--- a/pwb.py
+++ b/pwb.py
@@ -204,8 +204,8 @@
wait_time = config.pwb_autostart_waittime
output(color_format(
'NOTE: Starting the most similar script '
- '{lightyellow}{}.py{default}\n'
- ' in {} seconds; type CTRL-C to stop.',
+ '{lightyellow}{0}.py{default}\n'
+ ' in {1} seconds; type CTRL-C to stop.',
script, wait_time))
try:
sleep(wait_time) # Wait a bit to let it be cancelled
--
To view, visit https://gerrit.wikimedia.org/r/511919
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id848d585655ba6c7427789619e55dc2b7bfb8a83
Gerrit-Change-Number: 511919
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511874 )
Change subject: [bugfix] Fix TypeError in archivebot.py
......................................................................
[bugfix] Fix TypeError in archivebot.py
- Unfortunately frozenset and FrozenDict are not hashable (bug)?
- Using tuple instead
Bug: T224117
Change-Id: I6fb7928ca00e9091d333050992826c2f296ca6a6
---
M scripts/archivebot.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 59eeda8..5ea63ac 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -380,8 +380,8 @@
"""
Check whether thread has to be archived.
- @return: the archivation reason as a dict of localization args
- @rtype: dict
+ @return: the archivation reason as a tuple of localization args
+ @rtype: tuple
"""
# Archived by timestamp
algo = archiver.get_attr('algo')
@@ -393,7 +393,7 @@
maxage = str2time(re_t.group(1), self.timestamp)
if self.now - self.timestamp > maxage:
duration = str2localized_duration(archiver.site, re_t.group(1))
- return {'duration': duration}
+ return ('duration', duration)
# TODO: handle marked with template
return None
@@ -693,7 +693,7 @@
for a in self.archives.values())
# Find out the reasons and return them localized
translated_whys = set()
- for why, arg in whys.items():
+ for why, arg in whys:
# Archived by timestamp
if why == 'duration':
translated_whys.add(
--
To view, visit https://gerrit.wikimedia.org/r/511874
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6fb7928ca00e9091d333050992826c2f296ca6a6
Gerrit-Change-Number: 511874
Gerrit-PatchSet: 4
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511386 )
Change subject: [tests] remove botirc.py from coverage
......................................................................
[tests] remove botirc.py from coverage
botirc.py is deprecated and there are no tests to verify the code.
Remove this file from codecov.
Change-Id: Icda56658551f763556e7a63124bfcfabdce13891
---
M .codecov.yml
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.codecov.yml b/.codecov.yml
index b454e15..a3af5ff 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -16,6 +16,7 @@
ignore:
- pywikibot/compat
- pywikibot/backports.py
+ - pywikibot/botirc.py
- pywikibot/data/mysql.py
- pywikibot/families/__init__.py
- scripts/archive
--
To view, visit https://gerrit.wikimedia.org/r/511386
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Icda56658551f763556e7a63124bfcfabdce13891
Gerrit-Change-Number: 511386
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Xqt has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511382 )
Change subject: [tests] Use subTest to get all tests be processed
......................................................................
[tests] Use subTest to get all tests be processed
Normally a test method is exited if on assert failes and the other
tests aren't done. Use subTest to check all assertions in the given
method. This test is related to T223865 detecting the failure.
Note: subTest work on Python 3 only and is igrnored on Python 2.
Change-Id: I7273964e3449cac00d6562086c0f53ff57843e3d
---
M tests/page_tests.py
1 file changed, 8 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Dvorapa: Looks good to me, approved
diff --git a/tests/page_tests.py b/tests/page_tests.py
index f538463..55ce2fe 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1185,10 +1185,14 @@
"""Test create_short_link function."""
site = self.get_site()
p1 = pywikibot.Page(site, 'User:Framawiki/pwb_tests/shortlink')
- self.assertEqual(p1.create_short_link(), 'w.wiki/3Cy')
- self.assertEqual(p1.create_short_link(with_protocol=True),
- 'https://w.wiki/3Cy')
- self.assertEqual(p1.create_short_link(permalink=True), 'w.wiki/3Cz')
+ with self.subTest(parameters='defaulted'):
+ self.assertEqual(p1.create_short_link(), 'w.wiki/3Cy')
+ with self.subTest(with_protocol=True):
+ self.assertEqual(p1.create_short_link(with_protocol=True),
+ 'https://w.wiki/3Cy')
+ with self.subTest(permalink=True):
+ self.assertEqual(p1.create_short_link(permalink=True),
+ 'w.wiki/3Cz')
if __name__ == '__main__': # pragma: no cover
--
To view, visit https://gerrit.wikimedia.org/r/511382
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7273964e3449cac00d6562086c0f53ff57843e3d
Gerrit-Change-Number: 511382
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511399 )
Change subject: Removing @TODOs
......................................................................
Removing @TODOs
@TODOs were not meant to have been merged with the patchset. They
have been replaced with the following tasks.
Bug: T223889
Bug: T223890
Bug: T223891
Bug: T223897
Change-Id: I6f79c1ea55b0f1de0a8f33fb8ad78659c6c8c633
---
M pywikibot/page.py
1 file changed, 0 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 7013850..062ec9d 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -5609,9 +5609,6 @@
"""
Look up the namespace given the provided namespace id or name.
- @TODO Invalid namespaces are ignored as per Link.__init__,
- ideally both should raise some type of exception.
-
@rtype: pywikibot.Namespace
"""
default_nskey = Namespace.MAIN
@@ -5783,8 +5780,6 @@
following a '|' character inside the link
"""
- # @TODO Kept as is to not change repr() but is it suitable when missing
- # 3 of 5 attributes?
# Components used for __repr__
_items = ('title', 'site')
@@ -6090,7 +6085,6 @@
self.parse()
return self._anchor
- # @TODO: shouldn't anchor also be added?
def astext(self, onsite=None):
"""
Return a text representation of the link.
@@ -6107,7 +6101,6 @@
return text
- # @TODO: Left as is but shouldn't section be included per description?
def _cmpkey(self):
"""
Key for comparison of Link objects.
--
To view, visit https://gerrit.wikimedia.org/r/511399
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6f79c1ea55b0f1de0a8f33fb8ad78659c6c8c633
Gerrit-Change-Number: 511399
Gerrit-PatchSet: 2
Gerrit-Owner: Lokal Profil <andre.costa(a)wikimedia.se>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511404 )
Change subject: Localisation updates from https://translatewiki.net.
......................................................................
Localisation updates from https://translatewiki.net.
Change-Id: I2f38568951660635a5b03e4123e4287a9ad6af01
---
M checkimages/es.json
M checkimages/he.json
2 files changed, 11 insertions(+), 2 deletions(-)
Approvals:
L10n-bot: Looks good to me, approved
jenkins-bot: Verified
diff --git a/checkimages/es.json b/checkimages/es.json
index 168639e..0191ed3 100644
--- a/checkimages/es.json
+++ b/checkimages/es.json
@@ -2,9 +2,17 @@
"@metadata": {
"authors": [
"Macofe",
- "Fitoschido"
+ "Fitoschido",
+ "Ryo567"
]
},
+ "checkimages-doubles-file-comment": "Bot: Archivo ya en Commons, puede ser eliminado",
+ "checkimages-doubles-head": "Archivo duplicado",
+ "checkimages-doubles-talk-comment": "Bot: Notifica que el archivo ya existe en Commons",
+ "checkimages-log-comment": "Bot: Actualizando el registro",
+ "checkimages-no-license-head": "Imagen sin licencia",
"checkimages-source-tag-comment": "Robot: se marca un archivo sin etiquetas recién cargado",
- "checkimages-source-notice-comment": "Robot: se solicita información de la fuente."
+ "checkimages-source-notice-comment": "Robot: se solicita información de la fuente.",
+ "checkimages-unknown-extension-head": "¡Extensión desconocida!",
+ "checkimages-unknown-extension-msg": "El archivo %(file)s parece tener una extensión incorrecta, compruébalo."
}
diff --git a/checkimages/he.json b/checkimages/he.json
index 0ff1b43..0d8ea08 100644
--- a/checkimages/he.json
+++ b/checkimages/he.json
@@ -6,6 +6,7 @@
]
},
"checkimages-doubles-head": "קובץ כפול",
+ "checkimages-log-comment": "בוט: עדכון יומן",
"checkimages-no-license-head": "תמונה ללא רשיון",
"checkimages-source-tag-comment": "בוט: סימון קובץ חדש שהועלה ללא תיוג",
"checkimages-source-notice-comment": "בוט: בקשת מידע על מקור.",
--
To view, visit https://gerrit.wikimedia.org/r/511404
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2f38568951660635a5b03e4123e4287a9ad6af01
Gerrit-Change-Number: 511404
Gerrit-PatchSet: 1
Gerrit-Owner: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/442168 )
Change subject: Refactor Link
......................................................................
Refactor Link
Refactors Link in preparation for making sitelinks their own class.
BaseLink
- consists of a 'title', 'namespace' and 'site'
- constructor accepts 'namespace' as int, Namespace or local name
- constructor accepts 'site' as Site or dbname
- can be initialised from a Page object
Link
- extends BaseLink with 'section' and 'anchor'
- constructor expects the wikitext for a link and the site on which
the wikitext was found.
Bug: T66457
Change-Id: I3ac9057419a5aa61616c6623957614f82fefbf90
---
M pywikibot/page.py
1 file changed, 251 insertions(+), 96 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index ae28f9d..7013850 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -47,7 +47,8 @@
deprecated, deprecate_arg, deprecated_args, issue_deprecation_warning,
add_full_name, manage_wrapping,
ModuleDeprecationWrapper as _ModuleDeprecationWrapper, PY2,
- first_upper, redirect_func, remove_last_args, UnicodeType
+ first_upper, redirect_func, remove_last_args, UnicodeType,
+ StringTypes
)
from pywikibot.tools.ip import is_IP, ip_regexp
@@ -78,6 +79,7 @@
'Claim',
'Revision',
'FileInfo',
+ 'BaseLink',
'Link',
'html2unicode',
'UnicodeToAsciiHtml',
@@ -174,12 +176,12 @@
is the preferred syntax when using an already-normalized title
obtained from api.php or a database dump. WARNING: may produce
invalid objects if page title isn't in normal form!
- - If the first argument is a Link, create a Page from that link.
+ - If the first argument is a BaseLink, create a Page from that link.
This is the preferred syntax when using a title scraped from
wikitext, URLs, or another non-normalized source.
@param source: the source of the page
- @type source: Link, Page (or subclass), or Site
+ @type source: BaseLink (or subclass), Page (or subclass), or Site
@param title: normalized title of the page; required if source is a
Site, ignored otherwise
@type title: str
@@ -203,7 +205,7 @@
# overwrite title
self._link = Link(title, source=source.site,
default_namespace=ns)
- elif isinstance(source, Link):
+ elif isinstance(source, BaseLink):
self._link = source
self._revisions = {}
else:
@@ -240,10 +242,10 @@
def namespace(self):
"""
- Return the number of the namespace of the page.
+ Return the namespace of the page.
@return: namespace of the page
- @rtype: Namespace
+ @rtype: pywikibot.Namespace
"""
return self._link.namespace
@@ -322,8 +324,8 @@
"""
title = self._link.canonical_title()
label = self._link.title
- if with_section and self._link.section:
- section = '#' + self._link.section
+ if with_section and self.section():
+ section = '#' + self.section()
else:
section = ''
if as_link:
@@ -381,9 +383,13 @@
The section is the part of the title following a '#' character, if
any. If no section is present, return None.
- @rtype: str
+ @rtype: str or None
"""
- return self._link.section
+ try:
+ section = self._link.section
+ except AttributeError:
+ section = None
+ return section
def __unicode__(self):
"""Return a unicode string representation."""
@@ -5544,24 +5550,244 @@
return self.__dict__ == other.__dict__
-class Link(ComparableMixin):
+class BaseLink(ComparableMixin):
"""
A MediaWiki link (local or interwiki).
Has the following attributes:
- - site: The Site object for the wiki linked to
- - namespace: The namespace of the page linked to (int)
- title: The title of the page linked to (unicode); does not include
namespace or section
+ - namespace: The Namespace object of the page linked to
+ - site: The Site object for the wiki linked to
+ """
+
+ # Components used for __repr__
+ _items = ('title', 'namespace', '_sitekey')
+
+ def __init__(self, title, namespace=None, site=None):
+ """
+ Initializer.
+
+ @param title: the title of the page linked to (unicode); does not
+ include namespace or section
+ @type title: unicode
+ @param namespace: the namespace of the page linked to. Can be provided
+ as either an int, a Namespace instance or a str, defaults to the
+ MAIN namespace.
+ @type namespace: int, pywikibot.Namespace or str
+ @param site: the Site object for the wiki linked to. Can be provided as
+ either a Site instance or a db key, defaults to pywikibot.Site().
+ @type site: pywikibot.Site or str
+ """
+ self.title = title
+
+ if isinstance(namespace, pywikibot.site.Namespace):
+ self._namespace = namespace
+ else:
+ # postpone evaluation of namespace until needed
+ self._nskey = namespace
+
+ site = site or pywikibot.Site()
+ if isinstance(site, pywikibot.site.BaseSite):
+ self._site = site
+ self._sitekey = site.dbName()
+ else:
+ self._sitekey = site
+
+ def __repr__(self):
+ """Return a more complete string representation."""
+ assert isinstance(self._items, tuple)
+ assert all(isinstance(item, StringTypes) for item in self._items)
+
+ attrs = ('{0!r}'.format(getattr(self, attr)) for attr in self._items)
+ return 'pywikibot.page.{0}({1})'.format(
+ self.__class__.__name__, ', '.join(attrs))
+
+ def lookup_namespace(self):
+ """
+ Look up the namespace given the provided namespace id or name.
+
+ @TODO Invalid namespaces are ignored as per Link.__init__,
+ ideally both should raise some type of exception.
+
+ @rtype: pywikibot.Namespace
+ """
+ default_nskey = Namespace.MAIN
+ self._nskey = self._nskey or default_nskey
+
+ if isinstance(self._nskey, UnicodeType):
+ ns = self.site.namespaces.lookup_name(self._nskey)
+ if ns:
+ return ns
+ else:
+ self._nskey = default_nskey
+
+ if isinstance(self._nskey, int):
+ try:
+ ns = self.site.namespaces[self._nskey]
+ except KeyError:
+ ns = self.site.namespaces[default_nskey]
+ return ns
+
+ @property
+ def site(self):
+ """
+ Return the site of the link.
+
+ @rtype: pywikibot.Site
+ """
+ if not hasattr(self, '_site'):
+ self._site = pywikibot.site.APISite.fromDBName(self._sitekey)
+ return self._site
+
+ @property
+ def namespace(self):
+ """
+ Return the namespace of the link.
+
+ @rtype: pywikibot.Namespace
+ """
+ if not hasattr(self, '_namespace'):
+ self._namespace = self.lookup_namespace()
+ return self._namespace
+
+ def canonical_title(self):
+ """Return full page title, including localized namespace."""
+ # Avoid that ':' will be added to the title for Main ns.
+ if self.namespace != Namespace.MAIN:
+ return '%s:%s' % (self.site.namespace(self.namespace),
+ self.title)
+ else:
+ return self.title
+
+ def ns_title(self, onsite=None):
+ """
+ Return full page title, including namespace.
+
+ @param onsite: site object
+ if specified, present title using onsite local namespace,
+ otherwise use self canonical namespace.
+
+ @raise pywikibot.Error: no corresponding namespace is found in onsite
+ """
+ if onsite is None:
+ name = self.namespace.canonical_name
+ else:
+ # look for corresponding ns in onsite by name comparison
+ for alias in self.namespace:
+ namespace = onsite.namespaces.lookup_name(alias)
+ if namespace is not None:
+ name = namespace.custom_name
+ break
+ else:
+ # not found
+ raise pywikibot.Error(
+ 'No corresponding namespace found for namespace %s on %s.'
+ % (self.namespace, onsite))
+
+ if self.namespace != Namespace.MAIN:
+ return '%s:%s' % (name, self.title)
+ else:
+ return self.title
+
+ def astext(self, onsite=None):
+ """
+ Return a text representation of the link.
+
+ @param onsite: if specified, present as a (possibly interwiki) link
+ from the given site; otherwise, present as an internal link on
+ the site.
+ """
+ if onsite is None:
+ onsite = self.site
+ title = self.title
+ if self.namespace != Namespace.MAIN:
+ title = onsite.namespace(self.namespace) + ':' + title
+ if onsite == self.site:
+ return '[[%s]]' % title
+ if onsite.family == self.site.family:
+ return '[[%s:%s]]' % (self.site.code, title)
+ if self.site.family.name == self.site.code:
+ # use this form for sites like commons, where the
+ # code is the same as the family name
+ return '[[%s:%s]]' % (self.site.code, title)
+ return '[[%s:%s:%s]]' % (self.site.family.name, self.site.code, title)
+
+ if not PY2:
+ def __str__(self):
+ """Return a string representation."""
+ return self.__unicode__()
+ else: # PY2
+ def __str__(self):
+ """Return a string representation."""
+ return self.__bytes__()
+
+ def __bytes__(self):
+ """Return a byte representation."""
+ return self.astext().encode('ascii', 'backslashreplace')
+
+ def _cmpkey(self):
+ """
+ Key for comparison of BaseLink objects.
+
+ BaseLink objects are "equal" if and only if they are on the same site
+ and have the same normalized title.
+
+ BaseLink objects are sortable by site, then namespace, then title.
+ """
+ return (self.site, self.namespace, self.title)
+
+ def __unicode__(self):
+ """
+ Return a unicode string representation.
+
+ @rtype: str
+ """
+ return self.astext()
+
+ def __hash__(self):
+ """A stable identifier to be used as a key in hash-tables."""
+ return hash((self.site.sitename, self.canonical_title()))
+
+ @classmethod
+ def fromPage(cls, page):
+ """
+ Create a BaseLink to a Page.
+
+ @param page: target Page
+ @type page: Page
+
+ @rtype: BaseLink
+ """
+ title = page.title(with_ns=False,
+ allow_interwiki=False,
+ with_section=False)
+
+ return cls(title, namespace=page.namespace(), site=page.site)
+
+
+class Link(BaseLink):
+
+ """
+ A MediaWiki wikitext link (local or interwiki).
+
+ Constructs a Link object based on a wikitext link and a source site.
+
+ Extends BaseLink by the following attributes:
+
- section: The section of the page linked to (unicode or None); this
contains any text following a '#' character in the title
- anchor: The anchor text (unicode or None); this contains any text
following a '|' character inside the link
-
"""
+ # @TODO Kept as is to not change repr() but is it suitable when missing
+ # 3 of 5 attributes?
+ # Components used for __repr__
+ _items = ('title', 'site')
+
illegal_titles_pattern = re.compile(
# Matching titles will be held as illegal.
r'[\x00-\x1f\x23\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f]'
@@ -5648,10 +5874,6 @@
if source_is_page:
self._text = source.title(with_section=False) + self._text
- def __repr__(self):
- """Return a more complete string representation."""
- return 'pywikibot.page.Link(%r, %r)' % (self.title, self.site)
-
def parse_site(self):
"""
Parse only enough text to determine which site the link points to.
@@ -5829,7 +6051,7 @@
"""
Return the namespace of the link.
- @rtype: Namespace
+ @rtype: pywikibot.Namespace
"""
if not hasattr(self, '_namespace'):
self.parse()
@@ -5868,45 +6090,7 @@
self.parse()
return self._anchor
- def canonical_title(self):
- """Return full page title, including localized namespace."""
- # Avoid that ':' will be added to the title for Main ns.
- if self.namespace != Namespace.MAIN:
- return '%s:%s' % (self.site.namespace(self.namespace),
- self.title)
- else:
- return self.title
-
- def ns_title(self, onsite=None):
- """
- Return full page title, including namespace.
-
- @param onsite: site object
- if specified, present title using onsite local namespace,
- otherwise use self canonical namespace.
-
- @raise pywikibot.Error: no corresponding namespace is found in onsite
- """
- if onsite is None:
- name = self.namespace.canonical_name
- else:
- # look for corresponding ns in onsite by name comparison
- for alias in self.namespace:
- namespace = onsite.namespaces.lookup_name(alias)
- if namespace is not None:
- name = namespace.custom_name
- break
- else:
- # not found
- raise pywikibot.Error(
- 'No corresponding namespace found for namespace %s on %s.'
- % (self.namespace, onsite))
-
- if self.namespace != Namespace.MAIN:
- return '%s:%s' % (name, self.title)
- else:
- return self.title
-
+ # @TODO: shouldn't anchor also be added?
def astext(self, onsite=None):
"""
Return a text representation of the link.
@@ -5917,30 +6101,13 @@
"""
if onsite is None:
onsite = self._source
- title = self.title
- if self.namespace != Namespace.MAIN:
- title = onsite.namespace(self.namespace) + ':' + title
+ text = super(Link, self).astext(onsite)
if self.section:
- title = title + '#' + self.section
- if onsite == self.site:
- return '[[%s]]' % title
- if onsite.family == self.site.family:
- return '[[%s:%s]]' % (self.site.code, title)
- if self.site.family.name == self.site.code:
- # use this form for sites like commons, where the
- # code is the same as the family name
- return '[[%s:%s]]' % (self.site.code, title)
- return '[[%s:%s:%s]]' % (self.site.family.name, self.site.code, title)
+ text = '{0}#{1}]]'.format(text.rstrip(']'), self.section)
- if not PY2:
- def __str__(self):
- """Return a string representation."""
- return self.__unicode__()
- else:
- def __str__(self):
- """Return a string representation."""
- return self.astext().encode('ascii', 'backslashreplace')
+ return text
+ # @TODO: Left as is but shouldn't section be included per description?
def _cmpkey(self):
"""
Key for comparison of Link objects.
@@ -5952,18 +6119,6 @@
"""
return (self.site, self.namespace, self.title)
- def __unicode__(self):
- """
- Return a unicode string representation.
-
- @rtype: str
- """
- return self.astext()
-
- def __hash__(self):
- """A stable identifier to be used as a key in hash-tables."""
- return hash((self.site.sitename, self.canonical_title()))
-
@classmethod
def fromPage(cls, page, source=None):
"""
@@ -5976,13 +6131,13 @@
@rtype: Link
"""
+ base_link = BaseLink.fromPage(page)
link = cls.__new__(cls)
- link._site = page.site
+ link._site = base_link.site
+ link._title = base_link.title
+ link._namespace = base_link.namespace
+
link._section = page.section()
- link._namespace = page.namespace()
- link._title = page.title(with_ns=False,
- allow_interwiki=False,
- with_section=False)
link._anchor = None
link._source = source or pywikibot.Site()
--
To view, visit https://gerrit.wikimedia.org/r/442168
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ac9057419a5aa61616c6623957614f82fefbf90
Gerrit-Change-Number: 442168
Gerrit-PatchSet: 15
Gerrit-Owner: Lokal Profil <andre.costa(a)wikimedia.se>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <andre.costa(a)wikimedia.se>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Matěj Suchánek <matejsuchanek97(a)gmail.com>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511318 )
Change subject: [docs] Lower the warning in the docs
......................................................................
[docs] Lower the warning in the docs
Bug: T199933
Bug: T221801
Change-Id: I7ffd9a4bd007122fa39b1983d417125d9a6258f8
---
M docs/index.rst
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/index.rst b/docs/index.rst
index b471ea5..b9c0d80 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,9 +1,9 @@
Welcome to Pywikibot!
=====================
-.. warning::
+.. note::
- **This documentation is incomplete**, and needs quite some work.
+ This documentation is incomplete, and needs quite some work.
If you are not familiar with Pywikibot, please start at the
documentation:
--
To view, visit https://gerrit.wikimedia.org/r/511318
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ffd9a4bd007122fa39b1983d417125d9a6258f8
Gerrit-Change-Number: 511318
Gerrit-PatchSet: 2
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)