Revision: 4306 Author: cosoleto Date: 2007-09-16 14:29:52 +0000 (Sun, 16 Sep 2007)
Log Message: ----------- commons-like support for wikitravel shared site. Added fileIsShared() function in ImagePage class.
Modified Paths: -------------- trunk/pywikipedia/families/wikitravel_family.py trunk/pywikipedia/wikipedia.py
Added Paths: ----------- trunk/pywikipedia/families/wikitravel_shared_family.py
Modified: trunk/pywikipedia/families/wikitravel_family.py =================================================================== --- trunk/pywikipedia/families/wikitravel_family.py 2007-09-16 14:04:13 UTC (rev 4305) +++ trunk/pywikipedia/families/wikitravel_family.py 2007-09-16 14:29:52 UTC (rev 4306) @@ -52,5 +52,8 @@ def path(self, code): return '/wiki/%s/index.php' % code
+ def shared_image_repository(self, code): + return ('wikitravel_shared', 'wikitravel_shared') + def version(self, code): return "1.9.3"
Added: trunk/pywikipedia/families/wikitravel_shared_family.py =================================================================== --- trunk/pywikipedia/families/wikitravel_shared_family.py (rev 0) +++ trunk/pywikipedia/families/wikitravel_shared_family.py 2007-09-16 14:29:52 UTC (rev 4306) @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +__version__ = '$Id:' + +import family + +# The Wikitravel shared family + +class Family(family.Family): + def __init__(self): + family.Family.__init__(self) + self.name = 'wikitravel_shared' + self.langs = { + 'wikitravel_shared': 'wikitravel.org', + } + + self.namespaces[4] = { + '_default': [u'Wikitravel Shared', self.namespaces[4]['_default']], + } + self.namespaces[5] = { + '_default': [u'Wikitravel Shared talk', self.namespaces[5]['_default']], + } + + self.namespaces[200] = { + '_default': [u'Tech', self.namespaces[5]['_default']], + } + self.namespaces[201] = { + '_default': [u'Tech talk', self.namespaces[5]['_default']], + } + + self.interwiki_forward = 'wikitravel' + + def path(self, code): + return '/wiki/shared/index.php' + + def shared_image_repository(self, code): + return ('wikitravel_shared', 'wikitravel_shared') + + def version(self, code): + return "1.11alpha" +
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-09-16 14:04:13 UTC (rev 4305) +++ trunk/pywikipedia/wikipedia.py 2007-09-16 14:29:52 UTC (rev 4306) @@ -2156,6 +2156,11 @@ def fileIsOnCommons(self): return self.fileUrl().startswith(u'http://upload.wikimedia.org/wikipedia/commons/')
+ def fileIsShared(self): + if self.site().shared_image_repository()[0] == 'wikitravel_shared': + return self.fileUrl().startswith(u'http://wikitravel.org/upload/shared/') + return self.fileIsOnCommons() + def getFileMd5Sum(self): uo = MyURLopener() f = uo.open(self.fileUrl())
pywikipedia-l@lists.wikimedia.org