Page MenuHomePhabricator

Module 'pywikibot' has no 'url2link' member (pylint)
Closed, ResolvedPublic

Description

$ git grep -n url2link
scripts/checkimages.py:742: luser = pywikibot.url2link(nick, self.site, self.site)
scripts/welcome.py:602: username = pywikibot.url2link(usrna, self.site, self.site)
scripts/welcome.py:657: luser = pywikibot.url2link(result.name(), self.site, self.site)


Version: core-(2.0)
Severity: major

Details

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:49 AM
bzimport set Reference to bz73017.
bzimport added a subscriber: Unknown Object (????).

The code from compat is

def url2link(percentname, insite, site):
    """Convert urlname of a wiki page into interwiki link format.

    'percentname' is the page title as given by Page.urlname();
    'insite' specifies the target Site;
    'site' is the Site on which the page is found.

    """
    # Note: this is only needed if linking between wikis that use different
    # encodings, so it is now largely obsolete.  [CONFIRM]
    percentname = percentname.replace('_', ' ')
    x = url2unicode(percentname, site=site)
    return unicode2html(x, insite.encoding())

As welcome bot only works on a single site, it does not need to use this function, and should be updated to use existing methods.

checkimages does also access Wikimedia Commons, but as far as I can see Wikimedia Commons is not related to the call to function url2link, so again I think the code should be updated.

url2link should be added to README-conversion.txt / scripts/maintenance/compat2core.py , or it would also be useful to copy the missing function url2link from compat, and mark it as deprecated, so that old compat scripts work correctly.

Change 202438 had a related patch set uploaded (by John Vandenberg):
[FEAT] page: Port url2link from compat

https://gerrit.wikimedia.org/r/202438

Change 202438 abandoned by XZise:
[FEAT] page: Port url2link from compat

Reason:
If this function is still needed we can resurrect this. But as Xqt said there are ways using current code in core and the full capabilities of url2link aren't used anyway in compat.

https://gerrit.wikimedia.org/r/202438

Mpaa set Security to None.