User:YiFeiBot/wikiindex size.py: Difference between revisions
Jump to navigation
Jump to search
Zhuyifei1999 (talk | contribs) (Update -- somehow not working in date) |
Zhuyifei1999 (talk | contribs) (upd) |
||
Line 29: | Line 29: | ||
# script (i.e. wikiindex-size.py in this case) | # script (i.e. wikiindex-size.py in this case) | ||
def __init__(self, generator, summary, debug): | def __init__(self, generator, summary, debug=False): | ||
""" | """ | ||
Constructor. Parameters: | Constructor. Parameters: | ||
Line 40: | Line 40: | ||
self.generator = generator | self.generator = generator | ||
# init constants | # init constants | ||
self.site = pywikibot.getSite( | self.site = pywikibot.getSite("wikiindex", "wikiindex") | ||
# Set the edit summary message | # Set the edit summary message | ||
if summary: | if summary: | ||
Line 46: | Line 46: | ||
else: | else: | ||
self.summary = i18n.twtranslate(self.site, 'basic-changing') | self.summary = i18n.twtranslate(self.site, 'basic-changing') | ||
self.debug = debug | |||
def run(self): | def run(self): | ||
Line 65: | Line 62: | ||
newtext = text | newtext = text | ||
size_r = None | size_r = None | ||
size_r = re.compile(ur"""(?P<all>\{\{\s*Size\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*\}\} | size_r = re.compile(ur"""(?P<all>\{\{\s*Size\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*(\<!--manually add date when stats are verified and/or updated--\>)?)?)""") | ||
wtext = page.get() | wtext = page.get() | ||
Line 183: | Line 180: | ||
pywikibot.showDiff(page.get(), text) | pywikibot.showDiff(page.get(), text) | ||
pywikibot.output(u'Comment: %s' % comment) | pywikibot.output(u'Comment: %s' % comment) | ||
choice = pywikibot.inputChoice( | #choice = pywikibot.inputChoice( | ||
# u'Do you want to accept these changes?', | |||
# ['Yes', 'No'], ['y', 'N'], 'N') | |||
if | if True: | ||
try: | try: | ||
# Save the page | # Save the page | ||
Line 206: | Line 203: | ||
Line 365: | Line 231: | ||
pywikibot.output(u'Unknown argument: %s' % arg) | pywikibot.output(u'Unknown argument: %s' % arg) | ||
cat = catlib.Category(pywikibot.getSite(), 'Category:MediaWiki') | cat = catlib.Category(pywikibot.getSite("wikiindex", "wikiindex"), 'Category:MediaWiki') | ||
gen = pagegenerators.CategorizedPageGenerator(cat, start=start) | gen = pagegenerators.CategorizedPageGenerator(cat, start=start) | ||
Revision as of 12:49, 18 July 2013