Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mwlib/overlay.py
blob: 68c4774fec9599129e7c988b982d2c702af17ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# Copyright (c) 2007-2008 PediaPress GmbH
# See README.txt for additional licensing information.

import os

class OverlayDB(object):
    def __init__(self, db, basedir):
        self.db = db
        self.basedir = basedir

    def getRawArticle(self, title):
        p = os.path.join(self.basedir, title)
        if os.path.isfile(p):
            return unicode(open(p, 'rb').read(), 'utf-8')
        return self.db.getRawArticle(title)

    def getTemplate(self, title, followRedirects=False):
        p = os.path.join(self.basedir, title)
        if os.path.isfile(p):
            return unicode(open(p, 'rb').read(), 'utf-8')
        return self.db.getTemplate(title, followRedirects=followRedirects)