Revision: 7037 Author: alexsh Date: 2009-07-09 15:59:41 +0000 (Thu, 09 Jul 2009)
Log Message: ----------- * move SSL connection settings from family.py to SSL enabled family files.Its will override hostname, protocol, scriptpath and nicepath when config.SSL_connection is true. * remove urllib import in some family files (no need).
Modified Paths: -------------- trunk/pywikipedia/families/commons_family.py trunk/pywikipedia/families/incubator_family.py trunk/pywikipedia/families/mediawiki_family.py trunk/pywikipedia/families/meta_family.py trunk/pywikipedia/families/species_family.py trunk/pywikipedia/families/test_family.py trunk/pywikipedia/families/wikibooks_family.py trunk/pywikipedia/families/wikinews_family.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
Modified: trunk/pywikipedia/families/commons_family.py =================================================================== --- trunk/pywikipedia/families/commons_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/commons_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -14,7 +14,7 @@ 'commons': 'commons.wikimedia.org', } if config.SSL_connection: - self.langs['commons'] = 'secure.wikimedia.org' + self.langs['commons'] = None
self.namespaces[4] = { '_default': [u'Commons', 'Project'], @@ -62,8 +62,15 @@ def shared_image_repository(self, code): return ('commons', 'commons')
- def scriptpath(self, code): - if config.SSL_connection: + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): return '/wikipedia/commons/w'
- return '/w' + def nicepath(self, code): + return '/wikipedia/commons/wiki/' \ No newline at end of file
Modified: trunk/pywikipedia/families/incubator_family.py =================================================================== --- trunk/pywikipedia/families/incubator_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/incubator_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -14,7 +14,7 @@ 'incubator': 'incubator.wikimedia.org', } if config.SSL_connection: - self.langs['incubator'] = 'secure.wikimedia.org' + self.langs['incubator'] = None
self.namespaces[4] = { '_default': [u'Incubator', self.namespaces[4]['_default']], @@ -35,8 +35,16 @@ def shared_image_repository(self, code): return ('commons', 'commons')
- def scriptpath(self, code): - if config.SSL_connection: + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): return '/wikipedia/incubator/w' - - return '/w' + + def nicepath(self, code): + return '/wikipedia/incubator/wiki/' +
Modified: trunk/pywikipedia/families/mediawiki_family.py =================================================================== --- trunk/pywikipedia/families/mediawiki_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/mediawiki_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -16,7 +16,7 @@ 'mediawiki': 'www.mediawiki.org', } if config.SSL_connection: - self.langs['mediawiki'] = 'secure.wikimedia.org' + self.langs['mediawiki'] = None
self.namespaces[4] = { '_default': [u'Project', self.namespaces[4]['_default']], @@ -43,8 +43,15 @@ def shared_image_repository(self, code): return ('commons', 'commons')
- def scriptpath(self, code): - if config.SSL_connection: + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): return '/wikipedia/mediawiki/w' - - return '/w' + + def nicepath(self, code): + return '/wikipedia/mediawiki/wiki/'
Modified: trunk/pywikipedia/families/meta_family.py =================================================================== --- trunk/pywikipedia/families/meta_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/meta_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -15,7 +15,7 @@ }
if config.SSL_connection: - self.langs ['meta'] = 'secure.wikimedia.org' + self.langs ['meta'] = None
self.namespaces[4] = { '_default': [u'Meta', self.namespaces[4]['_default']], @@ -135,8 +135,15 @@ def shared_image_repository(self, code): return ('commons', 'commons')
- def scriptpath(self, code): - if config.SSL_connection: + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): return '/wikipedia/meta/w'
- return '/w' + def nicepath(self, code): + return '/wikipedia/meta/wiki/'
Modified: trunk/pywikipedia/families/species_family.py =================================================================== --- trunk/pywikipedia/families/species_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/species_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -14,7 +14,7 @@ 'species': 'species.wikimedia.org', } if config.SSL_connection: - self.langs['species'] = 'secure.wikimedia.org' + self.langs['species'] = None
self.namespaces[4] = { '_default': [u'Wikispecies', self.namespaces[4]['_default']], @@ -31,8 +31,15 @@ def shared_image_repository(self, code): return ('commons', 'commons')
- def scriptpath(self, code): - if config.SSL_connection: + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): return '/wikipedia/species/w'
- return '/w' + def nicepath(self, code): + return '/wikipedia/species/wiki/'
Modified: trunk/pywikipedia/families/test_family.py =================================================================== --- trunk/pywikipedia/families/test_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/test_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*-
-import family +__version__ = '$Id$'
+import family, config + # The test wikipedia family
class Family(family.Family): @@ -11,7 +13,10 @@ self.langs = { 'test': 'test.wikipedia.org', } + if config.SSL_connection: + self.langs['test'] = None
+ self.namespaces[4] = { '_default': [u'Wikipedia', self.namespaces[4]['_default']], } @@ -126,3 +131,16 @@
def shared_image_repository(self, code): return ('commons', 'commons') + + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): + return '/wikipedia/test/w' + + def nicepath(self, code): + return '/wikipedia/test/wiki/'
Modified: trunk/pywikipedia/families/wikibooks_family.py =================================================================== --- trunk/pywikipedia/families/wikibooks_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikibooks_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -348,13 +347,21 @@ # Global bot allowed languages on http://meta.wikimedia.org/wiki/Bot_policy/Implementation#Current_implementat... self.cross_allowed = ['fa', 'fy', 'it', 'ru', 'simple', 'zh']
- if config.SSL_connection: - def hostname(self, code): - return 'secure.wikimedia.org' - def version(self, code): return '1.16alpha'
def shared_image_repository(self, code): return ('commons', 'commons')
+ if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wikinews_family.py =================================================================== --- trunk/pywikipedia/families/wikinews_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikinews_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -193,12 +192,21 @@ def code2encoding(self, code): return 'utf-8'
+ def version(self, code): + return '1.16alpha' + + def shared_image_repository(self, code): + return ('commons', 'commons') + if config.SSL_connection: def hostname(self, code): return 'secure.wikimedia.org'
- def version(self, code): - return '1.16alpha' + def protocol(self, code): + return 'https'
- def shared_image_repository(self, code): - return ('commons', 'commons') \ No newline at end of file + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wikipedia_family.py =================================================================== --- trunk/pywikipedia/families/wikipedia_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikipedia_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -1125,4 +1124,13 @@
if config.SSL_connection: def hostname(self, code): - return 'secure.wikimedia.org' \ No newline at end of file + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wikiquote_family.py =================================================================== --- trunk/pywikipedia/families/wikiquote_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikiquote_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -263,10 +262,6 @@ 'zh-cn': 'zh' }
- if config.SSL_connection: - def hostname(self, code): - return 'secure.wikimedia.org' - def version(self, code): return '1.16alpha'
@@ -282,4 +277,17 @@ return self.code2encoding(code),
def shared_image_repository(self, code): - return ('commons', 'commons') \ No newline at end of file + return ('commons', 'commons') + + if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wikisource_family.py =================================================================== --- trunk/pywikipedia/families/wikisource_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikisource_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -350,21 +349,24 @@ 'el','fa','it','ko','no','zh' ]
- def scriptpath(self, code): - if config.SSL_connection: - if code == '-': - return '/wikipedia/sources/w' - - return '/%s/%s/w' % (self.name, code) - - return '/w' + def version(self, code): + return '1.16alpha'
+ def shared_image_repository(self, code): + return ('commons', 'commons') + if config.SSL_connection: def hostname(self, code): return 'secure.wikimedia.org'
- def version(self, code): - return '1.16alpha' + def protocol(self, code): + return 'https'
- def shared_image_repository(self, code): - return ('commons', 'commons') \ No newline at end of file + def scriptpath(self, code): + if code == '-': + return '/wikipedia/sources/w' + + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wikiversity_family.py =================================================================== --- trunk/pywikipedia/families/wikiversity_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wikiversity_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -119,12 +118,21 @@ 'ja', ]
+ def version(self,code): + return '1.16alpha' + + def shared_image_repository(self, code): + return ('commons', 'commons') + if config.SSL_connection: def hostname(self, code): return 'secure.wikimedia.org'
- def version(self,code): - return '1.16alpha' + def protocol(self, code): + return 'https'
- def shared_image_repository(self, code): - return ('commons', 'commons') \ No newline at end of file + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/families/wiktionary_family.py =================================================================== --- trunk/pywikipedia/families/wiktionary_family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/families/wiktionary_family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import urllib import family, config
__version__ = '$Id$' @@ -449,13 +448,21 @@
self.interwiki_attop = ['pl']
- if config.SSL_connection: - def hostname(self, code): - return 'secure.wikimedia.org' - def version(self, code): return '1.16alpha'
def shared_image_repository(self, code): return ('commons', 'commons')
+ if config.SSL_connection: + def hostname(self, code): + return 'secure.wikimedia.org' + + def protocol(self, code): + return 'https' + + def scriptpath(self, code): + return '/%s/%s/w' % (self.name, code) + + def nicepath(self, code): + return '/%s/%s/wiki/' % (self.name, code)
Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2009-07-09 12:16:32 UTC (rev 7036) +++ trunk/pywikipedia/family.py 2009-07-09 15:59:41 UTC (rev 7037) @@ -3525,9 +3525,6 @@ Can be overridden to return 'https'. Other protocols are not supported. """ - if config.SSL_connection: - return 'https' - return 'http'
def hostname(self, code): @@ -3545,9 +3542,6 @@ uses a different value.
""" - if config.SSL_connection: - return '/%s/%s/w' % (self.name, code) - return '/w'
def path(self, code): @@ -3560,9 +3554,6 @@ return '%s/api.php' % self.scriptpath(code)
def nicepath(self, code): - if config.SSL_connection: - return '/%s/%s/wiki/' % (self.name, code) - return '/wiki/'
def dbName(self, code):
pywikipedia-svn@lists.wikimedia.org