Last modified: 2014-09-11 16:34:49 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T72492, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 70492 - Make Page.interwiki() use api instead of parsing the text
Make Page.interwiki() use api instead of parsing the text
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized enhancement
: ---
Assigned To: Pywikipedia bugs
:
Depends on: 23524
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-06 14:04 UTC by Maarten Dammers
Modified: 2014-09-11 16:34 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Maarten Dammers 2014-09-06 14:04:20 UTC
In page.py in the Page object we have the following function:
https://git.wikimedia.org/blob/pywikibot%2Fcore.git/aba68924c8221f111fa28ebda34ea11c19f7d57f/pywikibot%2Fpage.py#L1113

    def interwiki(self, expand=True):
        """Iterate interwiki links in the page text, excluding language links.

        @param expand: if True (default), include interwiki links found in
            templates transcluded onto this page; if False, only iterate
            interwiki links found in this page's own wikitext
        @type expand: bool

        @return: a generator that yields Link objects
        """
        # This function does not exist in the API, so it has to be
        # implemented by screen-scraping

The MediaWiki api now has the function "iwlinks" (https://www.mediawiki.org/wiki/API:Iwlinks) that seems to do what we need. See for example https://commons.wikimedia.org/w/api.php?action=query&prop=iwlinks&titles=Creator:Antonio_Ponce&format=json

The interwiki() function should be reimplemented using the api.
Comment 1 Maarten Dammers 2014-09-06 14:19:30 UTC
Added the bug (23524) in which this was added. Shipped as part of MediaWiki 1.17
Comment 2 John Mark Vandenberg 2014-09-07 03:59:53 UTC
One problem is the API doesnt support 'expand=False' behaviour.  The API always includes all interlinks.  in your example

{
    "prefix": "w",
    "*": "Wikipedia:Transclusion"
},

A recent attempt to use both the API and textlib in the same Page method resulted in a stalemated patch with +2/-2: https://gerrit.wikimedia.org/r/#/c/148619/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links