Revision: 6628 Author: shizhao Date: 2009-04-18 16:57:21 +0000 (Sat, 18 Apr 2009)
Log Message: ----------- featuredcount.py all function have merge to featured.py. plese use:
featured.py -fromall -count
featuredcount.py move to /archive/
Added Paths: ----------- trunk/pywikipedia/archive/featuredcount.py
Removed Paths: ------------- trunk/pywikipedia/featuredcount.py
Added: trunk/pywikipedia/archive/featuredcount.py =================================================================== --- trunk/pywikipedia/archive/featuredcount.py (rev 0) +++ trunk/pywikipedia/archive/featuredcount.py 2009-04-18 16:57:21 UTC (rev 6628) @@ -0,0 +1,52 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +################################################## +This script all function have merge to featured.py. plese use: + + featured.py -fromall -count + +shizhao 2009-04-18 +################################################## + + +This script only counts how many featured articles all wikipedias have. + +usage: featuredcount.py + +""" +__version__ = '$Id: featuredcount.py 6336 2009-02-08 04:14:37Z purodha $' + +# +# Distributed under the terms of the MIT license. +# + +import sys +import wikipedia, catlib +from featured import featured_name + +def featuredArticles(site): + method=featured_name[site.lang][0] + name=featured_name[site.lang][1] + args=featured_name[site.lang][2:] + raw=method(site, name, *args) + arts=[] + for p in raw: + if p.namespace()==0: + arts.append(p) + elif p.namespace()==1: + arts.append(wikipedia.Page(p.site(), p.titleWithoutNamespace())) + wikipedia.output('\03{lightred}** wikipedia:%s has %i featured articles\03{default}' % (site.lang, len(arts))) + +if __name__=="__main__": + mysite = wikipedia.getSite() + fromlang = featured_name.keys() + fromlang.sort() + try: + for ll in fromlang: + fromsite = wikipedia.getSite(ll) + if fromsite != mysite: + arts = featuredArticles(fromsite) + arts_mysite = featuredArticles(mysite) + finally: + wikipedia.stopme()
Property changes on: trunk/pywikipedia/archive/featuredcount.py ___________________________________________________________________ Added: svn:eol-style + native
Deleted: trunk/pywikipedia/featuredcount.py =================================================================== --- trunk/pywikipedia/featuredcount.py 2009-04-18 16:47:40 UTC (rev 6627) +++ trunk/pywikipedia/featuredcount.py 2009-04-18 16:57:21 UTC (rev 6628) @@ -1,43 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -""" -This script only counts how many featured articles all wikipedias have. - -usage: featuredcount.py - -""" -__version__ = '$Id$' - -# -# Distributed under the terms of the MIT license. -# - -import sys -import wikipedia, catlib -from featured import featured_name - -def featuredArticles(site): - method=featured_name[site.lang][0] - name=featured_name[site.lang][1] - args=featured_name[site.lang][2:] - raw=method(site, name, *args) - arts=[] - for p in raw: - if p.namespace()==0: - arts.append(p) - elif p.namespace()==1: - arts.append(wikipedia.Page(p.site(), p.titleWithoutNamespace())) - wikipedia.output('\03{lightred}** wikipedia:%s has %i featured articles\03{default}' % (site.lang, len(arts))) - -if __name__=="__main__": - mysite = wikipedia.getSite() - fromlang = featured_name.keys() - fromlang.sort() - try: - for ll in fromlang: - fromsite = wikipedia.getSite(ll) - if fromsite != mysite: - arts = featuredArticles(fromsite) - arts_mysite = featuredArticles(mysite) - finally: - wikipedia.stopme()
pywikipedia-svn@lists.wikimedia.org