Mercurial > treepkg > treepkg
comparison treepkg/readconfig.py @ 114:02c261e4443f
Extend treepkg.readconfig.read_config:
- use import_packager_module
- allow %(name)s substitutions in packager_class values in the pkg_*
sections
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 01 Apr 2008 13:27:21 +0000 |
parents | 73c67372c7f7 |
children | d7b53e7df961 |
comparison
equal
deleted
inserted
replaced
113:312949e7628d | 114:02c261e4443f |
---|---|
1 # Copyright (C) 2007 by Intevation GmbH | 1 # Copyright (C) 2007, 2008 by Intevation GmbH |
2 # Authors: | 2 # Authors: |
3 # Bernhard Herzog <bh@intevation.de> | 3 # Bernhard Herzog <bh@intevation.de> |
4 # | 4 # |
5 # This program is free software under the GPL (>=v2) | 5 # This program is free software under the GPL (>=v2) |
6 # Read the file COPYING coming with the software for details. | 6 # Read the file COPYING coming with the software for details. |
10 import sys | 10 import sys |
11 import shlex | 11 import shlex |
12 from ConfigParser import SafeConfigParser, NoOptionError | 12 from ConfigParser import SafeConfigParser, NoOptionError |
13 | 13 |
14 import util | 14 import util |
15 import packager | |
15 | 16 |
16 defaults = dict(root_cmd="sudo") | 17 defaults = dict(root_cmd="sudo") |
17 | 18 |
18 packager_desc = [ | 19 packager_desc = [ |
19 "name", "base_dir", "svn_url", "packager_class", | 20 "name", "base_dir", "svn_url", "packager_class", |
60 | 61 |
61 # extract packager configurations | 62 # extract packager configurations |
62 packagers = [] | 63 packagers = [] |
63 for section in parser.sections(): | 64 for section in parser.sections(): |
64 if section.startswith("pkg_"): | 65 if section.startswith("pkg_"): |
65 packager_class = parser.get(section, "packager_class") | 66 vars = dict(name=section[4:]) |
66 module = util.import_dotted_name(packager_class) | 67 packager_class = parser.get(section, "packager_class", vars=vars) |
68 module = packager.import_packager_module(packager_class) | |
67 desc = packager_desc + module.PackageTrack.extra_config_desc | 69 desc = packager_desc + module.PackageTrack.extra_config_desc |
68 packagers.append(read_config_section(parser, section, desc, | 70 packagers.append(read_config_section(parser, section, desc, |
69 dict(name=section[4:]))) | 71 defaults=vars)) |
70 | 72 |
71 # main config | 73 # main config |
72 treepkg = read_config_section(parser, "treepkg", treepkg_desc) | 74 treepkg = read_config_section(parser, "treepkg", treepkg_desc) |
73 | 75 |
74 return treepkg, packagers | 76 return treepkg, packagers |