Revision: 6946 Author: alexsh Date: 2009-06-09 18:22:04 +0000 (Tue, 09 Jun 2009)
Log Message: ----------- *config.py -preSet globalAccount flag -remove no use comment. *family.py -add cross_allowed for global bot flag -update ns-info by update_namespaces.py *families -add allowed languages -update ns-info by update_namespaces.py -fix oldwikisource link faild when SSL *login.py:typo *spamremove.py:typo for syntax in msgs *speedy_delete.py:add new template for zhwiki *wikipedia.py -site._getUserData:detect global bot flag. -translate: add keyword "_default" -output: ignore print_stack raise None when OS in windows
Modified Paths: -------------- trunk/pywikipedia/config.py trunk/pywikipedia/families/wikipedia_family.py trunk/pywikipedia/families/wikiquote_family.py trunk/pywikipedia/families/wikisource_family.py trunk/pywikipedia/families/wikiversity_family.py trunk/pywikipedia/families/wiktionary_family.py trunk/pywikipedia/family.py trunk/pywikipedia/login.py trunk/pywikipedia/spamremove.py trunk/pywikipedia/speedy_delete.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py =================================================================== --- trunk/pywikipedia/config.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/config.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -44,6 +44,7 @@ sysopnames = {} disambiguation_comment = {} gdab_namespaces = {} +account_global = False
# Solve captchas in the webbrowser. Setting this to False will result in the # exception CaptchaError be thrown if a captcha is encountered. @@ -63,11 +64,7 @@ # 2. You must use the hostname of the site, not its family/language pair authenticate = {}
-# # Security Connection for Wikimedia Projects -# -# -# SSL_connection = False
# Available security projects @@ -75,11 +72,6 @@ u'wikipedia',u'wikinews',u'wikisource',u'wiktionary',u'wikibooks',u'wikiquote',u'wikiversity', u'meta',u'mediawiki',u'commons',u'species',u'incubator' ] -#] -# -# -# -# # password_file = ".passwd" # A password file with default passwords. For more information, please @@ -548,6 +540,7 @@ if _all or _glv[_name]!=globals()[_name]: print _name,"=",repr(globals()[_name])
+ # cleanup all locally-defined variables
for __var in globals().keys():
Modified: trunk/pywikipedia/families/wikipedia_family.py =================================================================== --- trunk/pywikipedia/families/wikipedia_family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/families/wikipedia_family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -409,7 +409,7 @@ 'als': u'Portal Diskussion', 'an': u'Descusión Portal', 'ar': u'نقاش البوابة', - 'arz': u'نقاش البوابة', + 'arz': u'مناقشة بوابة', 'bar': u'Portal Diskussion', 'be-x-old': u'Абмеркаваньне парталу', 'bg': u'Портал беседа', @@ -851,6 +851,22 @@ 'zh-min-nan': u'Khu-pia̍t-ia̍h', }
+ self.cross_allowed = [ + 'ab','af','ak','am','ang','arc','arz','as','av','ay','az','ba','bcl', + 'be-x-old','be','bg','bh','bi','bm','bo','bpy','bug','bxr','cbk-zam', + 'cdo','ce','ch','chy','co','crh','cr','csb','cu','diq','dsb','dz', + 'ee','eml','eu','ext','fa','ff','fj','fo','frp','fur','gan','ga','glk', + 'gn','got','gu','gv','ha','hak','haw','hif','hi','hsb','ht','hu','hy', + 'ia','ie','ig','ik','ilo','iow','iu','jbo','kaa','kab','ka','kg','ki', + 'kl','km','kn','ko','ks','ku','kv','kw','ky','lad','lbe','lg','li','lij', + 'lmo','ln','lo','map-bms','mdf','mg','mk','mn','myv','my','mzn','nah', + 'na','nds-nl','new','nl','nov','nrm','nv','ny','om','or','os','pam','pap', + 'pa','pdc','pnt','ps','qu','rm','rmy','rn','roa-rup','roa-tara','sah', + 'sa','sc','sco','sd','se','sg','sh','simple','si','sk','sm','sn','so', + 'srn','stq','st','su','sw','szl','ta','te','tet','tg','ti','tn','to', + 'tpi','ts','tt','tum','tw','ty','ug','uz','ve','wa','war','wo','wuu', + 'xal','xh','yi','yo','za','zh','zu' + ] # On most Wikipedias page names must start with a capital letter, but some # languages don't use this.
Modified: trunk/pywikipedia/families/wikiquote_family.py =================================================================== --- trunk/pywikipedia/families/wikiquote_family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/families/wikiquote_family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -62,6 +62,7 @@ 'sk': u'Wikicitáty', 'sl': u'Wikinavedek', 'tr': u'Vikisöz', + 'uk': u'Вікіцитати', 'ur': u'وکی اقتباسات', 'uz': u'Vikiiqtibos', } @@ -135,7 +136,7 @@ 'th': u'คุยเรื่องWikiquote', 'tr': u'Vikisöz tartışma', 'tt': u'Wikiquote bäxäse', - 'uk': u'Обговорення Wikiquote', + 'uk': u'Обговорення Вікіцитатей', 'ur': u'تبادلۂ خیال وکی اقتباسات', 'uz': u'Vikiiqtibos munozarasi', 'vi': u'Thảo luận Wikiquote', @@ -202,6 +203,11 @@ # List of languages that want the category on_one_line. self.category_on_one_line = []
+ + self.cross_allowed = [ + 'af','am','ang','ar','ast','az','da','fa','it', + 'ka','ko','la','nn','no','ro','simple','sv','zh' + ] # Which languages have a special order for putting interlanguage links, # and what order is it? If a language is not in interwiki_putfirst, # alphabetical order on language code is used. For languages that are in
Modified: trunk/pywikipedia/families/wikisource_family.py =================================================================== --- trunk/pywikipedia/families/wikisource_family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/families/wikisource_family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import urllib -import family, config, wikipedia +import family, config
__version__ = '$Id$'
@@ -20,7 +20,6 @@ 'gl', 'zh-min-nan', 'fo', ]
- self.langs['-'] = 'wikisource.org' if config.SSL_connection and self.name in config.available_ssl_project: for lang in self.languages_by_size: self.langs[lang] = 'secure.wikimedia.org' @@ -60,6 +59,7 @@ 'hu': u'Wikiforrás', 'hy': u'Վիքիդարան', 'is': u'Wikiheimild', + 'ko': u'위키문헌', 'la': u'Vicifons', 'li': u'Wikibrónne', 'lt': u'Vikišaltiniai', @@ -105,7 +105,7 @@ 'it': u'Discussioni Wikisource', 'ja': u'Wikisource‐ノート', 'kn': u'Wikisource ಚರ್ಚೆ', - 'ko': u'Wikisource토론', + 'ko': u'위키문헌토론', 'la': u'Disputatio Vicifontis', 'li': u'Euverlèk Wikibrónne', 'lt': u'Vikišaltiniai aptarimas', @@ -345,10 +345,19 @@ 'pl': self.alphabetic, 'simple': self.alphabetic } - if config.SSL_connection and wikipedia.default_code == '-': - def scriptpath(self, code): - return '/wikipedia/sources/w' - + self.cross_allowed = [ + 'el','fa','it','ko','no','zh' + ] + + def scriptpath(self, code): + if config.SSL_connection: + if code == '-': + return '/wikipedia/sources/w' + else: + return '/%s/%s/w' % (self.name, code) + else: + return '/w' + def version(self, code): return '1.15alpha'
Modified: trunk/pywikipedia/families/wikiversity_family.py =================================================================== --- trunk/pywikipedia/families/wikiversity_family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/families/wikiversity_family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -110,10 +110,15 @@ } self.namespaces[110] = { 'fr': u'Transwiki', + 'ja': u'Transwiki', } self.namespaces[111] = { 'fr': u'Discussion Transwiki', + 'ja': u'Transwiki‐ノート', } + self.cross_allowed = [ + 'ja', + ]
def version(self,code): return '1.15alpha'
Modified: trunk/pywikipedia/families/wiktionary_family.py =================================================================== --- trunk/pywikipedia/families/wiktionary_family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/families/wiktionary_family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -370,6 +370,10 @@ # letter on ALL Wiktionaries. self.nocapitalize = self.langs.keys()
+ self.cross_allowed = [ + 'ang','bg','bn','eo','fa','fy','gd','ia','ie','jv','ka','lt','mk', + 'nl','no','sk','th','ti','ts','uk','vo','za','zh-min-nan','zh', + ] self.obsolete = { 'aa': None, # http://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Afa... 'ab': None, # http://meta.wikimedia.org/wiki/Proposals_for_closing_projects/Closure_of_Abk...
Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/family.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -875,11 +875,15 @@ 4: { '_default': u'Project', 'cs': u'Wikizdroje', + 'ko': u'위키문헌', + 'uk': u'Вікіцитати', }, 5: { '_default': u'Project talk', 'cs': u'Wikizdroje diskuse', 'gan': u'Wikipedia talk', + 'ko': u'위키문헌토론', + 'uk': u'Обговорення Вікіцитатей', }, 6: { '_default': [u'File', u'Image'], @@ -2946,7 +2950,8 @@ self.disambiguationTemplates = { '_default': [] } - + # A list with the name in the cross-language flag permissions + self.cross_allowed = [] # A list with the name of the category containing disambiguation # pages for the various languages. Only one category per language, # and without the namespace, so add things like:
Modified: trunk/pywikipedia/login.py =================================================================== --- trunk/pywikipedia/login.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/login.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -298,7 +298,7 @@ for familyName in namedict.iterkeys(): for lang in namedict[familyName].iterkeys(): try: - site = wikipedia.getSite(code=lang, fam=familyName) + site = wikipedia.getSite( code=lang, fam=familyName ) if not forceLogin and site.loggedInAs(sysop = sysop) is not None: wikipedia.output(u'Already logged in on %s' % site) else:
Modified: trunk/pywikipedia/spamremove.py =================================================================== --- trunk/pywikipedia/spamremove.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/spamremove.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -37,7 +37,7 @@ 'en': u'Removing links to spamming site %s', 'es': u'Removiendo enlaces a sitio publicitario %s', 'he': u'מסיר קישורים לאתר ספאם %s', - 'fr': u'Suppression du lien blacklisté %s' + 'fr': u'Suppression du lien blacklisté %s', 'it': u'Rimuovo link contenuto nella Spam-Blacklist %s', 'ja': u'ロボットによる: 迷惑リンク削除 %s', 'nl': u'Links naar gespamde site: %s verwijderd',
Modified: trunk/pywikipedia/speedy_delete.py =================================================================== --- trunk/pywikipedia/speedy_delete.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/speedy_delete.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -120,6 +120,7 @@ }, 'zh':{ u'_default':u'[[WP:CSD]]', + u'Db-spam':u'[[WP:CSD#G11|CSD G11]]: 廣告、宣傳頁面', u'Notchinese':u'[[WP:CSD#G7|CSD G7]]: 非中文條目且長時間未翻譯', u'No source':u'[[WP:CSD#I3|CSD I3]]: 沒有來源連結,無法確認來源與版權資訊', u'No license':u'[[WP:CSD#I3|CSD I3]]: 沒有版權模板,無法確認版權資訊',
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-06-08 13:28:24 UTC (rev 6945) +++ trunk/pywikipedia/wikipedia.py 2009-06-09 18:22:04 UTC (rev 6946) @@ -4876,7 +4876,22 @@ # Check user groups, if possible (introduced in 1.10) groupsR = re.compile(r'var wgUserGroups = ["(.+)"];') m = groupsR.search(text) - if m: + checkLocal = True + if default_code in self.family.cross_allowed: # if current languages in cross allowed list, check global bot flag. + globalgroupsR = re.compile(r'var wgGlobalGroups = ["(.+)"];') + mg = globalgroupsR.search(text) + if mg: # the account had global permission + globalRights = mg.group(1) + globalRights = globalRights.split('","') + self._rights[index] = globalRights + if self._isLoggedIn[index]: + if 'Global_bot' in globalRights: # This account had global bot flag, no need to check local flags. + checkLocal = False + else: + output(u'Your bot account does not have global bot flag, checking local flag.') + else: + if verbose: output(u'Note:this language does not allowed global bot.') + if m and checkLocal: rights = m.group(1) rights = rights.split('", "') if '*' in rights: @@ -6441,8 +6456,8 @@ # about it. nonGlobalArgs.append(arg) if verbose: - output(u'Pywikipediabot %s' % (version.getversion())) - output(u'Python %s' % (sys.version)) + output('Pywikipediabot %s' % (version.getversion())) + output('Python %s' % (sys.version)) return nonGlobalArgs
######################### @@ -6604,7 +6619,7 @@ if hasattr(code,'lang'): code = code.lang
- if 'wikipedia' in xdict: + if 'wikipedia' in xdict: # If xdict attribute is wikipedia, define the xdite had multiple projects if default_family in xdict: xdict = xdict[default_family] else: @@ -6615,7 +6630,9 @@ for alt in altlang(code): if alt in xdict: return xdict[alt] - if 'en' in xdict: + if '_default' in xdict: + return xdict['_default'] + elif 'en' in xdict: return xdict['en'] return xdict.values()[0]
@@ -6759,7 +6776,7 @@ if decoder: text = unicode(text, decoder) elif type(text) is not unicode: - if verbose: + if verbose and sys.platform != 'win32': print "DBG> BUG: Non-unicode (%s) passed to wikipedia.output without decoder!" % type(text) print traceback.print_stack() print "DBG> Attempting to recover, but please report this problem"