Page MenuHomePhabricator

In site.loadrevisions page is mandatory even when revid is specified
Open, LowestPublic

Description

Hello,

according to help(site.loadrevisions) page (quoted below) is mandatory unless ids is specified. It doesn't work, through. See following output.

Steps to reproduce
$ python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywikibot
>>> site = pywikibot.Site()
>>> site.loadrevisions(revids=16114288)                                                                                                                                                                     
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/shared/pywikipedia/core/pywikibot/tools/__init__.py", line 1426, in wrapper
    return obj(*__args, **__kw)
TypeError: loadrevisions() takes at least 2 arguments (2 given)
>>> 
Help to site.loadrevisions
$ python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywikibot
>>> site = pywikibot.Site()
>>> help(site.loadrevisions)
Help on method loadrevisions in module pywikibot.site:

loadrevisions(*__args, **__kw) method of pywikibot.site.APISite instance
    Retrieve and store revision information.
    
    By default, retrieves the last (current) revision of the page,
    unless any of the optional parameters revids, startid, endid,
    starttime, endtime, rvdir, user, excludeuser, or limit are
    specified. Unless noted below, all parameters not specified
    default to False.
    
    If rvdir is False or not specified, startid must be greater than
    endid if both are specified; likewise, starttime must be greater
    than endtime. If rvdir is True, these relationships are reversed.
    
    @param page: retrieve revisions of this Page (required unless ids
        is specified)
    @param content: if True, retrieve the wiki-text of each revision;
        otherwise, only retrieve the revision metadata (default)
    @type content: bool
    @param section: if specified, retrieve only this section of the text
        (content must be True); section must be given by number (top of
        the article is section 0), not name
    @type section: int
    @param revids: retrieve only the specified revision ids (raise
        Exception if any of revids does not correspond to page
    @type revids: an int, a str or a list of ints or strings
    @param startid: retrieve revisions starting with this revid
    @param endid: stop upon retrieving this revid
    @param starttime: retrieve revisions starting at this Timestamp
    @param endtime: stop upon reaching this Timestamp
    @param rvdir: if false, retrieve newest revisions first (default);
        if true, retrieve earliest first
    @param user: retrieve only revisions authored by this user
    @param excludeuser: retrieve all revisions not authored by this user
    @param sysop: if True, switch to sysop account (if available) to
        retrieve this page

I think this should be fixed.

Martin

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as Medium priority.May 26 2018, 4:06 PM
Xqt added a project: good first task.

This is not trivial and I guess it shouldn't solved in the proposed manner. loadrevisions() is not a function but a method that loads revisions for a given page. Ok the revisions may be given by the revids but the page object is needed to hold the revisions and this is done by api.update_page() at the bottom of this method. You cannot ommit the page parameter because there is no other object to hold the revisions otherwise. Therefore I propose to decline this request then. But some clearer docs could be made.

Xqt lowered the priority of this task from Medium to Lowest.May 26 2018, 4:50 PM

Change 435646 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [doc] Update Site.loadrevisions doc string

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

What should I do if I want to know what page contains revision with revid 1?

What should I do if I want to know what page contains revision with revid 1?

How do you got the revision id?

Change 435646 merged by jenkins-bot:
[pywikibot/core@master] [doc] Update Site.loadrevisions doc string

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

What should I do if I want to know what page contains revision with revid 1?

Maybe we should have a new site method load_pages_from_revids(self, revids)

Xqt removed Xqt as the assignee of this task.May 28 2018, 5:24 AM
Xqt subscribed.
Vvjjkkii renamed this task from In site.loadrevisions page is mandatory even when revid is specified to l8baaaaaaa.Jul 1 2018, 1:07 AM
Vvjjkkii raised the priority of this task from Lowest to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
CommunityTechBot renamed this task from l8baaaaaaa to In site.loadrevisions page is mandatory even when revid is specified.Jul 2 2018, 7:31 AM
CommunityTechBot lowered the priority of this task from High to Lowest.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.