Revision: 5090
Author: russblau
Date: 2008-02-27 20:33:11 +0000 (Wed, 27 Feb 2008)
Log Message:
-----------
remove families that don't support api.php; bring api.py up to date
Modified Paths:
--------------
branches/rewrite/pywikibot/data/api.py
branches/rewrite/pywikibot/tests/api_tests.py
Removed Paths:
-------------
branches/rewrite/pywikibot/families/betawiki_family.py
branches/rewrite/pywikibot/families/gentoo_family.py
branches/rewrite/pywikibot/families/loveto_family.py
branches/rewrite/pywikibot/families/lyricwiki_family.py
branches/rewrite/pywikibot/families/mdc_family.py
branches/rewrite/pywikibot/families/mozilla_family.py
branches/rewrite/pywikibot/families/openttd_family.py
branches/rewrite/pywikibot/families/wikibond_family.py
branches/rewrite/pywikibot/families/wikitravel_family.py
branches/rewrite/pywikibot/families/wikitravel_shared_family.py
branches/rewrite/pywikibot/tests/dummy.py
Modified: branches/rewrite/pywikibot/data/api.py
===================================================================
--- branches/rewrite/pywikibot/data/api.py 2008-02-27 20:26:53 UTC (rev 5089)
+++ branches/rewrite/pywikibot/data/api.py 2008-02-27 20:33:11 UTC (rev 5090)
@@ -19,6 +19,7 @@
import time
import urllib
+import pywikibot
from pywikibot import login
@@ -241,10 +242,10 @@
# method that converts the dict info to a Page object
if isinstance(query["pages"], dict):
for v in query["pages"].itervalues():
- yield Page(self.site, v['title'])
+ yield pywikibot.Page(self.site, v['title'])
elif isinstance(query["pages"], list):
for v in query["pages"]:
- yield Page(self.site, v['title'])
+ yield pywikibot.Page(self.site, v['title'])
else:
raise APIError("Unknown",
"Unknown format in ['query']['pages']
value.",
Deleted: branches/rewrite/pywikibot/families/betawiki_family.py
===================================================================
--- branches/rewrite/pywikibot/families/betawiki_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/betawiki_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,34 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from pywikibot import family
-
-# The official Beta Wiki.
-class Family(family.Family):
-
- def __init__(self):
-
- family.Family.__init__(self)
- self.name = 'betawiki' #Set the family name; this should be the same as
in the filename.
-
- self.langs = {
- 'en': 'www.ucip.org', #Put the hostname here.
- }
-
- self.namespaces[4] = {
- '_default': [u'BetaWiki',
self.namespaces[4]['_default']],
- }
-
- self.namespaces[5] = {
- '_default': [u'BetaWiki talk',
self.namespaces[5]['_default']],
- }
-
- def version(self, code):
- return "1.5.4" #The MediaWiki version used. Not very important in most
cases.
-
- def scriptpath(self, code):
- return '/beta' #The value of {{SCRIPTPATH}} on this wiki
-
- def apipath(self, code):
- # Betawiki uses old, pre-API MediaWiki version
- raise NotImplementedError(
- "The %s family does not support api.php" % self.name)
Deleted: branches/rewrite/pywikibot/families/gentoo_family.py
===================================================================
--- branches/rewrite/pywikibot/families/gentoo_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/gentoo_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,80 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import urllib
-from pywikibot import family
-import config
-
-__version__ = '$Id$'
-
-# An inofficial Gentoo wiki project.
-# Ask for permission at
http://gentoo-wiki.com/Help:Bots before running a bot.
-# Be very careful, and set a long throttle: "until we see it is good one edit
-# ever minute and one page fetch every 30 seconds, maybe a *bit* faster later".
-
-class Family(family.Family):
-
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'gentoo'
-
- self.langs = {
- 'en':'gentoo-wiki.com',
- 'de':'de.gentoo-wiki.com',
- 'es':'es.gentoo-wiki.com',
- 'fr':'fr.gentoo-wiki.com',
- 'he':'he.gentoo-wiki.com',
- 'hu':'hu.gentoo-wiki.com',
- 'nl':'nl.gentoo-wiki.com',
- 'pt':'pt.gentoo-wiki.com',
- 'ru':'ru.gentoo-wiki.com',
- 'zh':'zh.gentoo-wiki.com',
- }
-
- # TODO: sort
- self.languages_by_size = ['en', 'de', 'es', 'fr',
'he', 'hu', 'nl', 'pt', 'ru', 'zh']
-
- # he: also uses the default 'Media'
- del self.namespaces[-2]['he']
-
- self.namespaces[4] = {
- '_default': [u'Gentoo Linux Wiki',
self.namespaces[4]['_default']],
- }
- self.namespaces[5] = {
- '_default': [u'Gentoo Linux Wiki talk',
self.namespaces[5]['_default']],
- 'de': u'Gentoo Linux Wiki Diskussion',
- 'es': u'Gentoo Linux Wiki Discusión',
- 'fr': u'Discussion Gentoo Linux Wiki',
- 'he': u'שיחת Gentoo Linux Wiki',
- 'hu': u'Gentoo Linux Wiki vita',
- 'nl': u'Overleg Gentoo Linux Wiki',
- 'pt': u'Gentoo Linux Wiki Discussão',
- 'ru': u'Обсуждение Gentoo Linux Wiki',
- }
- self.namespaces[100] = {
- '_default': [u'Index'],
- }
- self.namespaces[101] = {
- '_default': [u'Index Talk'],
- }
- self.namespaces[110] = {
- '_default': [u'Ucpt'],
- }
- self.namespaces[111] = {
- '_default': [u'Ucpt talk'],
- }
-
- self.known_families.pop('gentoo-wiki')
-
- def scriptpath(self, code):
- return ''
-
- def apipath(self, code):
- # API not implemented on this wiki
- raise NotImplementedError(
- "The %s family does not yet support api.php." % self.name())
-
- def nicepath(self, code):
- return '/'
-
- def version(self, code):
- return "1.9alpha"
Deleted: branches/rewrite/pywikibot/families/loveto_family.py
===================================================================
--- branches/rewrite/pywikibot/families/loveto_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/loveto_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,120 +0,0 @@
-# -*- coding: utf-8 -*-
-from pywikibot import family
-
-# The Lovetoknow internal family, for lovetoknow wikis, including those
-# not yet open to the public.
-
-class Family(family.Family):
- def __init__(self):
- family.Family.__init__(self)
-
- self.name = 'loveto'
-
- self.langs = {
- '1911': '1911encyclopedia',
- 'recipes': 'recipes',
- 'video': 'videogames',
- 'garden': 'garden',
- 'guru': 'webguru',
- 'baby': 'baby',
- 'business': 'business',
- 'buy': 'buy',
- 'crafts': 'crafts',
- 'diet': 'diet',
- 'engagement': 'engagementrings',
- 'kids': 'kids',
- 'pregnancy': 'pregnancy',
- 'sanfrancisco': 'sanfrancisco',
- 'scifi': 'sci-fi',
- 'travel': 'travel',
- 'weddings': 'weddings',
- 'wine': 'wine',
- 'online': 'online',
- 'movies': 'movies',
- 'dogs': 'dogs',
- 'shoes': 'shoes',
- 'cruises': 'cruises',
- 'recovery': 'addiction',
- 'insurance': 'insurance',
- 'makeup': 'makeup',
- 'skincare': 'skincare',
- 'lingerie': 'lingerie',
- 'mortgage': 'mortgage',
- 'interiordesign': 'interiordesign',
- 'tattoos': 'tattoos',
- 'hair': 'hair',
- 'dating': 'dating',
- 'cellphones': 'cellphones',
- 'college': 'college',
- 'yoga': 'yoga',
- 'celebrity': 'celebrity',
- 'sunglasses': 'sunglasses',
- 'divorce': 'divorce',
- 'creditcards': 'creditcards',
- 'cats': 'cats',
- 'swimsuits': 'swimsuits',
- 'watches': 'watches',
- }
-
- self.namespaces[4]['1911'] = '1911 Encylopedia'
- self.namespaces[5]['1911'] = '1911 Encylopedia talk'
-
- self.namespaces[4]['recipes'] = 'LoveToKnow Recipes'
- self.namespaces[5]['recipes'] = 'Talk:LoveToKnow Recipes'
- self.disambiguationTemplates = {
- '_default': [],
- '1911': ['Disamb'],
- }
-
- self.disambcatname = {
- '1911': 'Disambiguation',}
-
- def scriptpath(self, code):
- if code in
['1911','shoes','insurance','makeup','skincare','lingerie',
-
'mortgage','interiordesign','tattoos','hair','dating',
-
'cellphones','college','yoga','celebrity','sunglasses',
-
'divorce','creditcards','cats','swimsuits']:
- return ''
- else:
- return '/w'
-
- def apipath(self, code):
- raise NotImplementedError(
- "The lovetoknow family does not support api.php")
-
- def nice_get_address(self, code, name):
- if code in ['recipes','garden','guru']:
- return '/wiki/%s' % (name)
- else:
- return '/%s' % (name)
-
- # Which version of MediaWiki is used?
- def version(self, code):
- return "1.8.2"
-
- def hostname(self,code):
- if code == '1911':
- return 'www.1911encyclopedia.org'
- elif code == 'guru':
- return 'www.webguru.com'
- else:
- return self.langs[code] + '.lovetoknow.com'
-
- def RversionTab(self, code):
- if code == '1911':
- return(r"action=history")
- elif code == 'recipes':
- return(r"table\>\s*\<b>Format")
- elif code == 'crafts':
- return(r'contentSub"></div>\s*<b>Format')
- elif code in
['kids','pregnancy','weddings','wine','tattoos','hair',
- 'dating','celebrity']:
- return(r"div>\s*<b>Formatting")
- else:
- return(r"div>\s*<script")
-
- def edit_address(self, code, name):
- if code == 'recipes':
- return '%s?title=%s&action=edit&masteredit=1' %
(self.path(code), name)
- else:
- return '%s?title=%s&action=edit' % (self.path(code), name)
Deleted: branches/rewrite/pywikibot/families/lyricwiki_family.py
===================================================================
--- branches/rewrite/pywikibot/families/lyricwiki_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/lyricwiki_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,33 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from pywikibot import family
-
-# The LyricWiki family
-
-# user_config.py:
-# usernames['lyricwiki']['en'] = 'user'
-
-class Family(family.Family):
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'lyricwiki'
- self.langs = {
- 'en': 'www.lyricwiki.org',
- }
-
- self.namespaces[4] = {
- '_default': [u'LyricWiki',
self.namespaces[4]['_default']],
- }
- self.namespaces[5] = {
- '_default': [u'LyricWiki talk',
self.namespaces[5]['_default']],
- }
-
- def version(self, code):
- return "1.7.1"
-
- def scriptpath(self, code):
- return ''
-
- def apipath(self, code):
- raise NotImplementedError(
- "The lyricwiki family does not support api.php")
Deleted: branches/rewrite/pywikibot/families/mdc_family.py
===================================================================
--- branches/rewrite/pywikibot/families/mdc_family.py 2008-02-27 20:26:53 UTC (rev 5089)
+++ branches/rewrite/pywikibot/families/mdc_family.py 2008-02-27 20:33:11 UTC (rev 5090)
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-from pywikibot import family
-
-# The Mozilla Developer Center, Official Mozilla Documents.
-
-class Family(family.Family):
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'mdc'
-
- self.langs = {
- 'ca': None,
- 'cn': None,
- 'de': None,
- 'en': None,
- 'es': None,
- 'fr': None,
- 'it': None,
- 'ja': None,
- 'ko': None,
- 'nl': None,
- 'pl': None,
- 'pt': None,
- 'zh_tw':None,
- }
-
- self.namespaces[4] = {
- '_default': u'MDC',
- }
-
- self.namespaces[5] = {
- '_default': u'MDC talk',
- 'ca': u'MDC Discussió',
- 'cn': u'MDC talk',
- 'de': u'MDC Diskussion',
- 'es': u'MDC Discusión',
- 'fr': u'Discussion MDC',
- 'it': u'Discussioni MDC',
- 'ja': u'MDC�?ノート',
- 'ko': u'MDC토론',
- 'nl': u'Overleg MDC',
- 'pl': u'Dyskusja MDC',
- 'pt': u'MDC Discussão',
- }
-
- def hostname(self,code):
- return 'developer.mozilla.org'
-
- def scriptpath(self, code):
- return '/'+code+'/docs'
-
- def apipath(self, code):
- raise NotImplementedError(
- "The mdc family does not support api.php")
-
- def version(self, code):
- return "1.9.3"
Deleted: branches/rewrite/pywikibot/families/mozilla_family.py
===================================================================
--- branches/rewrite/pywikibot/families/mozilla_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/mozilla_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from pywikibot import family
-
-# The official Mozilla Wiki.
-
-class Family(family.Family):
- def __init__(self):
- family.Family.__init__(self)
-
- self.name = 'mozilla'
-
- self.langs = {
- 'en': 'wiki.mozilla.org',
- }
- self.namespaces[4] = {
- '_default': [u'MozillaWiki',
self.namespaces[4]['_default']],
- }
- self.namespaces[5] = {
- '_default': [u'MozillaWiki talk',
self.namespaces[5]['_default']],
- }
-
- self.content_id = "mainContent"
-
- def RversionTab(self, code):
- return r'<li\s*><a
href=".*?title=.*?&action=history".*?>.*?</a></li>'
-
- def version(self, code):
- return "1.10.2"
-
- def scriptpath(self, code):
- return ''
-
- def apipath(self, code):
- raise NotImplementedError(
- "The mozilla family does not support api.php")
Deleted: branches/rewrite/pywikibot/families/openttd_family.py
===================================================================
--- branches/rewrite/pywikibot/families/openttd_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/openttd_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-
-__version__ = '$Id$'
-
-from pywikibot import family
-
-# The project wiki of OpenTTD, an open source game (Transport Tycoon Deluxe clone).
-
-class Family(family.Family):
-
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'openttd'
- self.langs = {
- 'en': 'wiki.openttd.org',
- }
-
- self.namespaces[4] = {
- '_default': [u'OpenTTD',
self.namespaces[4]['_default']],
- }
- self.namespaces[5] = {
- '_default': [u'OpenTTD talk',
self.namespaces[5]['_default']],
- }
- self.namespaces[100] = {
- '_default': u'Manual',
- }
- self.namespaces[101] = {
- '_default': u'Development',
- }
-
- def scriptpath(self, code):
- return ''
-
- def version(self, code):
- return "1.9.1"
-
- def apipath(self, code):
- raise NotImplementedError(
- "The openttd family does not support api.php")
Deleted: branches/rewrite/pywikibot/families/wikibond_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikibond_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/wikibond_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,31 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from pywikibot import family
-
-# I added this becouse someone asked me to.
-# The url op the wiki:
nl.wikibond.org
-
-class Family(family.Family):
-
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'wikibond'
- self.langs = {
- 'nl': 'nl.wikibond.org',
- }
- self.namespaces[4] = {
- 'nl': [u'WikiBond'],
- }
- self.namespaces[5] = {
- 'nl': [u'Overleg WikiBond'],
- }
-
- def scriptpath(self, code):
- return '/wikibond'
-
- def version(self, code):
- return "1.11alpha"
-
- def apipath(self, code):
- raise NotImplementedError(
- "The wikibond family does not support api.php")
Deleted: branches/rewrite/pywikibot/families/wikitravel_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikitravel_family.py 2008-02-27 20:26:53 UTC (rev
5089)
+++ branches/rewrite/pywikibot/families/wikitravel_family.py 2008-02-27 20:33:11 UTC (rev
5090)
@@ -1,64 +0,0 @@
-from pywikibot import family
-import config
-
-# The wikitravel family
-
-# Translation used on all wikitravels for the 'article' text.
-# A language not mentioned here is not known by the robot
-
-__version__ = '$Id$'
-
-class Family(family.Family):
- def __init__(self):
- family.Family.__init__(self)
- self.name = 'wikitravel'
- self.langs = {
- 'ca':'ca',
- 'de':'de',
- 'en':'en',
- 'eo':'eo',
- 'es':'es',
- 'fi':'fi',
- 'fr':'fr',
- 'he':'he',
- 'hi':'hi',
- 'hu':'hu',
- 'it':'it',
- 'ja':'ja',
- 'nl':'nl',
- 'pl':'pl',
- 'pt':'pt',
- 'ro':'ro',
- 'ru':'ru',
- 'sv':'sv',
- }
- self.namespaces[4] = {
- '_default': [u'Wikitravel',
self.namespaces[4]['_default']],
- }
- self.namespaces[5] = {
- '_default': [u'Wikitravel talk',
self.namespaces[5]['_default']],
- 'de': u'Wikitravel Diskussion',
- }
-
- # A few selected big languages for things that we do not want to loop over
- # all languages. This is only needed by the titletranslate.py module, so
- # if you carefully avoid the options, you could get away without these
- # for another wikimedia family.
-
- self.languages_by_size = ['en','fr','ro']
-
- def hostname(self,code):
- return 'wikitravel.org'
-
- def scriptpath(self, code):
- return '/wiki/%s' % code
-
- def apipath(self, code):
- raise NotImplementedError(
- "The wikitravel family does not support api.php")
-
- def shared_image_repository(self, code):
- return ('wikitravel_shared', 'wikitravel_shared')
-
- def version(self, code):
- return "1.10.1"
Deleted: branches/rewrite/pywikibot/families/wikitravel_shared_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikitravel_shared_family.py 2008-02-27 20:26:53
UTC (rev 5089)
+++ branches/rewrite/pywikibot/families/wikitravel_shared_family.py 2008-02-27 20:33:11
UTC (rev 5090)
@@ -1,44 +0,0 @@
-# -*- coding: utf-8 -*-
-
-__version__ = '$Id$'
-
-from pywikibot 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 scriptpath(self, code):
- return '/wiki/shared'
-
- def apipath(self, code):
- raise NotImplementedError(
- "The wikitravel_shared family does not support api.php")
-
- def shared_image_repository(self, code):
- return ('wikitravel_shared', 'wikitravel_shared')
-
- def version(self, code):
- return "1.10.1"
-
Modified: branches/rewrite/pywikibot/tests/api_tests.py
===================================================================
--- branches/rewrite/pywikibot/tests/api_tests.py 2008-02-27 20:26:53 UTC (rev 5089)
+++ branches/rewrite/pywikibot/tests/api_tests.py 2008-02-27 20:33:11 UTC (rev 5090)
@@ -1,8 +1,8 @@
import unittest
+import pywikibot
import pywikibot.data.api as api
-from pywikibot.tests.dummy import TestSite as Site, TestPage as Page
-mysite = Site('en.wikipedia.org')
+mysite = pywikibot.Site('en', 'wikipedia')
class TestApiFunctions(unittest.TestCase):
@@ -59,7 +59,7 @@
results = [p for p in self.gen]
self.assertEqual(len(results), 4)
for page in results:
- self.assertEqual(type(page), Page)
+ self.assertEqual(type(page), pywikibot.Page)
self.assertEqual(page.site(), mysite)
self.assert_(page.title() in titles)
Deleted: branches/rewrite/pywikibot/tests/dummy.py
===================================================================
--- branches/rewrite/pywikibot/tests/dummy.py 2008-02-27 20:26:53 UTC (rev 5089)
+++ branches/rewrite/pywikibot/tests/dummy.py 2008-02-27 20:33:11 UTC (rev 5090)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Dummy objects for use in unit tests."""
-#
-# (C) Pywikipedia bot team, 2007
-#
-# Distributed under the terms of the MIT license.
-#
-__version__ = '$Id: $'
-
-# add in any other attributes or methods that are needed for testing
-
-class TestSite(object):
- """Mimic a Site object."""
- def __init__(self, hostname, protocol="http", path="w/"):
- self._hostname = hostname
- self._protocol = protocol
- self._path = path
- def protocol(self):
- return self._protocol
- def hostname(self):
- return self._hostname
- def script_path(self):
- return self._path
- def cookies(self, sysop=False):
- if hasattr(self, "_cookies"):
- return self._cookies
- return u""
-
-
-class TestPage(object):
- """Mimic a Page object."""
- def __init__(self, site, title):
- self._site = site
- self._title = title
- def site(self):
- return self._site
- def title(self):
- return self._title
-