simple_family.py :  » Network » Python-Wikipedia-Robot-Framework » pywikipedia » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Network » Python Wikipedia Robot Framework 
Python Wikipedia Robot Framework » pywikipedia » simple_family.py
# -*- coding: utf-8  -*- 

# ============================================
# NOTE FOR USERS: Unlike the Family files in 
# the family # directory, you do not need to 
# edit this file to configure anything.
# ============================================

# (C) Kim Bruning for Wikiation, sponsored by Kennisnet, 2009
#
# Distributed under the terms of the MIT license.
#

import sys #, settings    # No such module settings
#if settings.pywikipedia_path not in sys.path:
#    sys.path.append(settings.pywikipedia_path)

import config, family, urllib   
class Family(family.Family): 
    """Friendlier version of the pywikipedia family class.
    We can use this in conjunction with none-pywikipedia
    config files.
    
    Note that this just handles most common cases.
    If you run into a special case, you'll have to fall back
    to your regular pywikipedia.
    """
    
    def __init__(self,
        name='MY_NAME_FOR_THIS_SERVER',
        protocol='http',
        server='www.my_server.com',
        scriptpath='/my/script/path',
        version='1.13.2',
        lang='en',
        encoding='utf-8',
        api_supported=False,    
        RversionTab=None    # very rare beast, you probably won't need it.
        ):              
        """name: arbitrary name. Pick something easy to remember
        protocol: http|https
        server: dns address or ip address
        scriptpath: path on server itself
            (ie:  protocol:server/scriptpath   http://6.wikiation.nl/revisions/REL1.13.2)
        version: mediawiki version of the target mediawiki instance
        lang: default language, as configured on target mediawiki instance
        encoding: should (almost) always be utf-8
        api_supported: Does this mediawiki instance support the mediawiki api?
        RversionTab: Magic. See superclass for information.
        """

        family.Family.__init__(self) 
        self.name = name        # REQUIRED; replace with actual name

        self.langs = {                # REQUIRED
            lang: server,  # Include one line for each wiki in family
        }
        self._protocol=protocol
        self._scriptpath=scriptpath
        self._version=version
        self._encoding=encoding
        # may as well add these here, so we can have a 1 stop shop
        self._lang=lang
        self._server=server
        self._api_supported=api_supported
        self._RversionTab=RversionTab

    def protocol(self, code):
        """
        returns "http" or "https"
    """
        return self._protocol

    def scriptpath(self, code):
        """returns the prefix used to locate scripts on this wiki.
        """
        return self._scriptpath

    def apipath(self, code):
        """returns whether or not this wiki 
        """
        if self._api_supported:
            return '%s/api.php' % self.scriptpath(code)
        else:
            raise NotImplementedError, "%s wiki family does not support api.php" % self.name

    # Which version of MediaWiki is used?
    def version(self, code):
        # Replace with the actual version being run on your wiki
        return self._version

    def code2encoding(self, code):
        """Return the encoding for a specific language wiki"""
        # Most wikis nowadays use UTF-8, but change this if yours uses
        # a different encoding
        return self._encoding

    def RversionTab(self, code):
        return self._RversionTab
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.