http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10450
Revision: 10450 Author: xqt Date: 2012-07-09 10:29:36 +0000 (Mon, 09 Jul 2012) Log Message: ----------- untabify script, redefine skips dictionary; better raise a key error if _default entry doesn't exist
Modified Paths: -------------- trunk/pywikipedia/tag_nowcommons.py
Modified: trunk/pywikipedia/tag_nowcommons.py =================================================================== --- trunk/pywikipedia/tag_nowcommons.py 2012-07-09 09:48:21 UTC (rev 10449) +++ trunk/pywikipedia/tag_nowcommons.py 2012-07-09 10:29:36 UTC (rev 10450) @@ -5,7 +5,7 @@ """ # # (C) Multichill, 2011 -# (C) xqt,2011 +# (C) xqt, 2012 # # Distributed under the terms of the MIT license. # @@ -22,38 +22,39 @@ from pywikibot import i18n
-skips = {} -skips['wikipedia'] = {} -skips['wikipedia']['en'] = [u'NowCommons', - u'CommonsNow', - u'Nowcommons', - u'NowCommonsThis', - u'Nowcommons2', - u'NCT', - u'Nowcommonsthis', - u'Moved to commons', - u'Now Commons', - u'Now at commons', - u'Db-nowcommons', - u'WikimediaCommons', - u'Now commons', - u'Do not move to Commons', - u'KeepLocal', - u'Keeplocal', - u'NoCommons', - u'Nocommons', - u'NotMovedToCommons', - u'Nmtc', - u'Not moved to Commons', - u'Notmovedtocommons', - ] -skips['wikipedia']['fy'] = [u'NowCommons', - u'Nowcommons', - ] -skips['_default'] = [u'NowCommons'] +skips = { + '_default': [u'NowCommons'], + 'wikipedia': { + 'en': [u'NowCommons', + u'CommonsNow', + u'Nowcommons', + u'NowCommonsThis', + u'Nowcommons2', + u'NCT', + u'Nowcommonsthis', + u'Moved to commons', + u'Now Commons', + u'Now at commons', + u'Db-nowcommons', + u'WikimediaCommons', + u'Now commons', + u'Do not move to Commons', + u'KeepLocal', + u'Keeplocal', + u'NoCommons', + u'Nocommons', + u'NotMovedToCommons', + u'Nmtc', + u'Not moved to Commons', + u'Notmovedtocommons', + ], + 'fy': [u'NowCommons', + u'Nowcommons', + ], + }, +}
- class NoEnoughData(pywikibot.Error): """ Error class for when the user doesn't specified all the data needed """
@@ -67,10 +68,10 @@
if not imagepage.fileIsOnCommons():
- if skips.get(family) and skips.get(family).get(language): - localskips = skips.get(family).get(language) + if family in skips and language in skips[family]: + localskips = skips[family][language] else: - localskips = skips.get('_default') + localskips = skips['_default']
for template in imagepage.templates(): #FIXME: Move the templates list to a lib.
pywikipedia-svn@lists.wikimedia.org