User:YiFeiBot/wikiindex size.py: Difference between revisions
Jump to navigation
Jump to search
Zhuyifei1999 (talk | contribs) (upd) |
Zhuyifei1999 (talk | contribs) (readable) |
||
Line 4: | Line 4: | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
# | # | ||
__version__ = '$Id: | __version__ = '$Id: NULL $' | ||
# | # | ||
Line 40: | Line 40: | ||
self.generator = generator | self.generator = generator | ||
# init constants | # init constants | ||
self.site = pywikibot.getSite(" | self.site = pywikibot.getSite("en", "wikiindex") | ||
# Set the edit summary message | # Set the edit summary message | ||
if summary: | if summary: | ||
Line 62: | Line 62: | ||
newtext = text | newtext = text | ||
size_r = None | size_r = None | ||
size_r = re.compile(ur"""(?P<all>\{\{\s* | size_r = re.compile(ur"""(?P<all>\{\{\s*[Ss]ize\s*((\|\s*(?P<pages>pages|wiki[ _]pages)\s*=\s*(?P<pages_value>\d*)\s*[^\|\}]*\s*)|(\s*\|\s*(?P<pagesurl>statistics[ _]URL|wiki[ _]statistics[ _]URL)\s*=\s*(?P<pagesurl_value>https?://[^ \|\}\<]*)\s*[^\|\}]*\s*)|(\s*\|\s*(?P<wikifactor>wikiFactor)\s*=\s*(?P<wikifactor_value>\d*)\s*[^\|\}]*\s*)|(\s*\|\s*(?P<wikifactorurl>wikiFactor[ _]URL)\s*=\s*(?P<wikifactorurl_value>http://[^ \|\}\<]*)\s*[^\|\}]*\s*))+\s*\|?\s*\}\}(\s*\([Aa]s\s*of:?\s*(?P<day>\d+)\s*(?P<month>[A-Z][a-z]+)\s*(?P<year>\d+)\s*\)\s*(\<!--[ A-Za-z0-9/]+--\>)?)?)""") | ||
wtext = page.get() | wtext = page.get() | ||
Line 85: | Line 85: | ||
if self.debug: | if self.debug: | ||
pywikibot.output(u"text = | pywikibot.output(u"text = " + text) | ||
pywikibot.output(u"all = | pywikibot.output(u"all = " + all) | ||
pywikibot.output(u"pages = | pywikibot.output(u"pages = " + pages) | ||
pywikibot.output(u"pagesurl = | pywikibot.output(u"pagesurl = " + pagesurl) | ||
pywikibot.output(u"wikifactor = | pywikibot.output(u"wikifactor = " + wikifactor) | ||
pywikibot.output(u"wikifactorurl = | pywikibot.output(u"wikifactorurl = " + wikifactorurl) | ||
pywikibot.output(u"pages_value = | pywikibot.output(u"pages_value = " + pages_value) | ||
pywikibot.output(u"pagesurl_value = | pywikibot.output(u"pagesurl_value = " + pagesurl_value) | ||
pywikibot.output(u"wikifactor_value = | pywikibot.output(u"wikifactor_value = " + wikifactor_value) | ||
pywikibot.output(u"wikifactorurl_value = | pywikibot.output(u"wikifactorurl_value = " + wikifactorurl_value) | ||
pywikibot.output(u"day = | pywikibot.output(u"day = " + day) | ||
pywikibot.output(u"month = | pywikibot.output(u"month = " + month) | ||
pywikibot.output(u"year = | pywikibot.output(u"year = " + year) | ||
#get new values | #get new values | ||
Line 147: | Line 147: | ||
| %s = %s <!--preferred; if unknown leave void; see: Category:wikiFactor for help--> | | %s = %s <!--preferred; if unknown leave void; see: Category:wikiFactor for help--> | ||
| %s = %s <!--wF source (often 'PopularPages', 'Mostvisitedpages' or 'PageHits'); if unknown leave void--> | | %s = %s <!--wF source (often 'PopularPages', 'Mostvisitedpages' or 'PageHits'); if unknown leave void--> | ||
}}(As of: %s %s %s)<!--manually add/amend date when stats are verified and/or updated-->""" % ( | }}(As of: %s %s %s)<!--manually add/amend date when stats are verified and/or updated-->""" % ( | ||
pages or 'pages', | |||
pages_value or '', | |||
pagesurl or 'statistics URL', | |||
pagesurl_value or '', | |||
wikifactor or 'wikiFactor', | |||
wikifactor_value or '', | |||
wikifactorurl or 'wikiFactor URL', | |||
wikifactorurl_value or '', | |||
day or '', | |||
month or '', | |||
year or '') | |||
newtext = text.replace(all, newvalues) | newtext = text.replace(all, newvalues) | ||
Line 231: | Line 242: | ||
pywikibot.output(u'Unknown argument: %s' % arg) | pywikibot.output(u'Unknown argument: %s' % arg) | ||
cat = catlib.Category(pywikibot.getSite(" | cat = catlib.Category(pywikibot.getSite("en", "wikiindex"), 'Category:MediaWiki') | ||
gen = pagegenerators.CategorizedPageGenerator(cat, start=start) | gen = pagegenerators.CategorizedPageGenerator(cat, start=start) | ||
Latest revision as of 06:34, 25 August 2014