Revision: 7737
Author: filnik
Date: 2009-12-06 14:05:17 +0000 (Sun, 06 Dec 2009)
Log Message:
-----------
Bugfix: whitelist not used with this script. Please stop adding bugs to my script, thanks. Or, at least, fix them before committing..
Modified Paths:
--------------
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2009-12-05 21:27:58 UTC (rev 7736)
+++ trunk/pywikipedia/welcome.py 2009-12-06 14:05:17 UTC (rev 7737)
@@ -560,22 +560,21 @@
del list_white, whitelist_default
try:
- for bname in self._blacklist:
- if bname.lower() in str(name.lower()): #bad name positive
- self.bname = bname
- return True
- except UnicodeEncodeError:
- pass
- try:
for wname in self._whitelist:
- if wname.lower() in str(name.lower()):
- name = name.replace(wname.lower(), '')
+ if wname.lower() in str(name).lower():
+ name = name.lower().replace(wname.lower(), '')
for bname in self._blacklist:
self.bname = bname
return bname.lower() in name.lower()
except UnicodeEncodeError:
- pass
-
+ pass
+ try:
+ for bname in self._blacklist:
+ if bname.lower() in str(name).lower(): #bad name positive
+ self.bname = bname
+ return True
+ except UnicodeEncodeError:
+ pass
return False
def reportBadAccount(self, name = None, final = False):
@@ -824,7 +823,6 @@
us = self._parseNewUserLogOld()
else:
us = self.parseNewUserLog()
-
for users in us:
if users.isBlocked():
showStatus(3)
Revision: 7732
Author: alexsh
Date: 2009-12-04 14:51:07 +0000 (Fri, 04 Dec 2009)
Log Message:
-----------
fix -lang no work, and comment out zh regex cause no using and changed for logn time (re-checking current datas).
Modified Paths:
--------------
trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2009-12-03 18:28:57 UTC (rev 7731)
+++ trunk/pywikipedia/blockpageschecker.py 2009-12-04 14:51:07 UTC (rev 7732)
@@ -82,7 +82,7 @@
r'\{\{(?:[Tt]emplate:|)[Aa]bp(?:|[ _]scad\|(?:.*?))\}\}'],
'fr': [ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Ss]emi[- ]?protection(|[^\}]*)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)半保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- 'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)'],
+ #'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the total-protection template
templateTotalProtection = {
@@ -92,21 +92,21 @@
'fr':[ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Pp]rotection(|[^\}]*)\}\}',
ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)(?:[Pp]age|[Aa]rchive|[Mm]odèle) protégée?(|[^\}]*)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)保護(?:性急|)(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- 'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)'],
+ #'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the semi-protection move template
templateSemiMoveProtection = {
'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[ _]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動半保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- 'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)'],
+ #'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the total-protection move template
templateTotalMoveProtection = {
'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[ _]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- 'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)'],
+ #'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)'],
}
# If you use only one template for all the type of protection, put it here.
@@ -122,7 +122,7 @@
'it':['{{Avvisobloccoparziale}}', '{{Avvisoblocco}}', None, None, '{{Protetta}}'],
'fr':['{{Semi-protection}}', '{{Protection}}', None, None, None],
'ja':[u'{{半保護}}', u'{{保護}}', u'{{移動半保護}}', u'{{移動保護}}', None],
- 'zh':[u'{{Protected/semi}}',u'{{Protected}}',u'{{Protected/ms}}',u'{{Protected/move}}', None],
+ #'zh':[u'{{Protected/semi}}',u'{{Protected}}',u'{{Protected/ms}}',u'{{Protected/move}}', None],
}
# Category where the bot will check
@@ -206,7 +206,7 @@
def main():
""" Main Function """
# Loading the comments
- global categoryToCheck; global comment; global project_inserted
+ global categoryToCheck, comment, project_inserted
if config.mylang not in project_inserted:
pywikibot.output(u"Your project is not supported by this script. You have to edit the script and add it!")
return
@@ -215,8 +215,6 @@
moveBlockCheck = False; genFactory = pagegenerators.GeneratorFactory()
# To prevent Infinite loops
errorCount = 0
- # Load the right site
- site = pywikibot.getSite()
# Loading the default options.
for arg in pywikibot.handleArgs():
if arg == '-always':
@@ -244,6 +242,9 @@
else:
genFactory.handleArg(arg)
+ # Load the right site
+ site = pywikibot.getSite()
+
# Take the right templates to use, the category and the comment
TSP = pywikibot.translate(site, templateSemiProtection)
TTP = pywikibot.translate(site, templateTotalProtection)
Revision: 7730
Author: alexsh
Date: 2009-12-03 09:57:03 +0000 (Thu, 03 Dec 2009)
Log Message:
-----------
Site().siteinfo(): add dump for return all info, mass siprop single output handle.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2009-12-02 16:50:10 UTC (rev 7729)
+++ trunk/pywikipedia/wikipedia.py 2009-12-03 09:57:03 UTC (rev 7730)
@@ -5210,6 +5210,7 @@
raise NoSuchSite("Language %s does not exist in family %s"%(self.lang,self.family.name))
self._mediawiki_messages = {}
+ self._info = {}
self.nocapitalize = self.lang in self.family.nocapitalize
self.user = user
self._userData = [False, False]
@@ -6064,42 +6065,61 @@
# Token not found
output(u'WARNING: Token not found on %s. You will not be able to edit any page.' % self)
- def siteinfo(self, key = 'general', force = False): #, dump = False
+ def siteinfo(self, key = 'general', force = False, dump = False):
"""Get Mediawiki Site informations by API
dump - return all siteinfo datas
+
+ some siprop params is huge data for MediaWiki, they take long times to read by testment.
+ these params could get, but only one by one.
+
"""
- if hasattr(self, '_info') and key in self._info and not force:
- return self._info[key]
+ # protection for key in other datatype
+ if type(key) not in [str, unicode]:
+ key = 'general'
+ if self._info and key in self._info and not force:
+ if dump:
+ return self._info
+ else:
+ return self._info[key]
+
params = {
'action':'query',
'meta':'siteinfo',
'siprop':['general', 'namespaces', ],
}
+ #ver 1.10 handle
if self.versionnumber() > 10:
params['siprop'].extend(['statistics', ])
- #'specialpagealiases', 'interwikimap', 'namespacealiases', 'usergroups',
+ if key in ['specialpagealiases', 'interwikimap', 'namespacealiases', 'usergroups', ]:
+ if verbose: print 'getting huge siprop %s...' % key
+ params['siprop'] = [key]
+
+ #ver 1.13 handle
if self.versionnumber() > 13:
- params['siprop'].extend(['fileextensions', 'rightsinfo', ])
- #'magicwords', 'extensions',
+ if key not in ['specialpagealiases', 'interwikimap', 'namespacealiases', 'usergroups', ]:
+ params['siprop'].extend(['fileextensions', 'rightsinfo', ])
+ if key in ['magicwords', 'extensions', ]:
+ if verbose: print 'getting huge siprop %s...' % key
+ params['siprop'] = [key]
try:
data = query.GetData(params, self)['query']
- if not hasattr(self, '_info'):
- self._info = data
+ except NotImplementedError:
+ return None
+
+ if not hasattr(self, '_info'):
+ self._info = data
+ else:
+ for k, v in data.iteritems():
+ self._info[k] = v
+ #data pre-process
+ try:
+ if dump:
+ return self._info
else:
- for k, v in data.iteritems():
- #if k in self._info:
- # if v != self._info[k]: self._info[k] = v
- #else:
- self._info[k] = v
-
- try:
return self._info[key]
- except KeyError:
- return None
- except NotImplementedError:
- self._info = {}
- return False
+ except KeyError:
+ return None
def mediawiki_message(self, key, forceReload = False):