[Pywikipedia-l] [Pywikipedia-svn] SVN: [6942] trunk/pywikipedia

Francesco Cosoleto cosoleto at gmail.com
Sun Jun 7 09:18:10 UTC 2009


purodha at svn.wikimedia.org ha scritto:
> Revision: 6942
> Author:   purodha
> Date:     2009-06-07 05:24:19 +0000 (Sun, 07 Jun 2009)
> 
> Log Message:
> -----------
> Initial version of a recentchenges page generator (via API)
> 
[...]
> +    def recentchanges(self, number = 100, rcstart = None, rcend = None, rcshow = None, rctype ='edit|new', repeat = False):
> +        """
> +        Yield ImagePages from APIs, call: action=query&list=recentchanges&rctype=edit|new&rclimit=500

Yield Pages. API. URL may be removed.

> +
> +        Options directly from APIs:

API.

> +        while True:
> +            data = query.GetData(params,
> +                            useAPI = True, encodeTitle = False)

A site parameter to GetData() call should be added, else it works only 
with default family and language.

Probably in query module the old Query API support may be removed, so 
'useAPI' parameter becomes useless.

> +            try:
> +                rcData = data['query']['recentchanges']
> +            except KeyError:
> +                raise ServerError("The APIs don't return data, the site may be down")

"MediaWiki API doesn't"

Probably this code should be adapted and noved to GetData() function in 
query module.

> +            for rcItem in rcData:
> +                try:
> +                    comment = rcItem['comment']
> +                except KeyError:
> +                    comment = ''

comment = ''
if 'comment' in rcItem:
     comment = ...

> +                try:
> +                    loginfo = rcItem['loginfo']
> +                except KeyError:
> +                    loginfo = ''

as suggested above

> +            if not repeat:
> +                break
> +

'repeat' parameter should be removed (and the same in others Site methods).

-- 
Francesco Cosoleto

«Non dee l'uomo, per maggiore amico, dimenticare li servigi ricevuti dal 
minore». (Dante Alighieri, Convivio, II, 65)




More information about the Pywikipedia-l mailing list