~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to tests/maketestwiki.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
"""
3
 
MoinMoin - make a test wiki
4
 
 
5
 
Usage:
6
 
 
7
 
    maketestwiki.py
8
 
 
9
 
@copyright: 2005 by Thomas Waldmann
10
 
@license: GNU GPL, see COPYING for details.
11
 
"""
12
 
 
13
 
import os, sys, shutil, errno, tarfile
14
 
 
15
 
moinpath = os.path.join(os.path.dirname(sys.argv[0]), os.pardir)
16
 
sys.path.insert(0, os.path.abspath(moinpath))
17
 
 
18
 
WIKI = os.path.abspath('testwiki')
19
 
SHARE = os.path.abspath('wiki')
20
 
 
21
 
def removeTestWiki():
22
 
    print 'removing old wiki ...'
23
 
    for dir in ['data', 'underlay']:
24
 
        try:
25
 
            shutil.rmtree(os.path.join(WIKI, dir))
26
 
        except OSError, err:
27
 
            if not (err.errno == errno.ENOENT or
28
 
                    (err.errno == 3 and os.name == 'nt')):
29
 
                raise
30
 
 
31
 
def copyData():
32
 
    print 'copying data ...'
33
 
    src = os.path.join(SHARE, 'data')
34
 
    dst = os.path.join(WIKI, 'data')
35
 
    shutil.copytree(src, dst)
36
 
    # Remove arch-ids dirs
37
 
    for path, dirs, files in os.walk(dst):
38
 
        for dir in dirs[:]:
39
 
            if dir == '.arch-ids':
40
 
                shutil.rmtree(os.path.join(path, dir))
41
 
                dirs.remove(dir)
42
 
 
43
 
 
44
 
def untarUnderlay():
45
 
    print 'untaring underlay ...'
46
 
    tar = tarfile.open(os.path.join(SHARE, 'underlay.tar.bz2'), mode='r:bz2')
47
 
    for member in tar:
48
 
        tar.extract(member, WIKI)
49
 
    tar.close()
50
 
 
51
 
 
52
 
def run():
53
 
    try:
54
 
        os.makedirs(WIKI)
55
 
    except OSError, e:
56
 
        if e.errno != errno.EEXIST:
57
 
            raise
58
 
 
59
 
    removeTestWiki()
60
 
    copyData()
61
 
    untarUnderlay()
62
 
 
63
 
if __name__ == '__main__':
64
 
    run()
65