Mercurial > treepkg > treepkg
annotate treepkg/readconfig.py @ 521:d26642ed6afa
use empty string as default config values instead of None
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Wed, 10 Nov 2010 16:48:03 +0000 |
parents | f2de1c162d30 |
children |
rev | line source |
---|---|
234
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
167
diff
changeset
|
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
0 | 2 # Authors: |
3 # Bernhard Herzog <bh@intevation.de> | |
4 # | |
5 # This program is free software under the GPL (>=v2) | |
6 # Read the file COPYING coming with the software for details. | |
7 | |
8 """Reads the configuration file""" | |
9 | |
10 import sys | |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
11 import shlex |
391
89ecca5d262e
check if config file exists to get usefull error output
Bjoern Ricks <bricks@intevation.de>
parents:
389
diff
changeset
|
12 import os.path |
0 | 13 from ConfigParser import SafeConfigParser, NoOptionError |
14 | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
15 import util |
114
02c261e4443f
Extend treepkg.readconfig.read_config:
Bernhard Herzog <bh@intevation.de>
parents:
93
diff
changeset
|
16 import packager |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
17 |
129
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
18 def convert_bool(s): |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
19 s = s.lower() |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
20 if s in ("true", "yes", "1"): |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
21 return True |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
22 if s in ("false", "no", "0"): |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
23 return False |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
24 raise ValueError("cannot determine boolean value of %r" % (s,)) |
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
25 |
0 | 26 |
304
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
27 def convert_subversion_subset(raw): |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
28 """Converts the string representation an svn subset into internal form |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
29 The format in the config file is typically: |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
30 url: svn://example.com/repository/trunk |
304
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
31 svn_subset: -N . |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
32 subdir1 |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
33 subdir2 |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
34 |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
35 Each line of the svn_subset value consists of an optional flag |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
36 followed by a subdirectory. Empty lines are ignored. Each |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
37 non-empty line is split into words using shlex.split, so whitespace |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
38 characters can be included in filenames using e.g. quotes (see the |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
39 shlex documentation for details). The only flag supported is -N |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
40 which indicates that the subdirectory on that line is not to be |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
41 checked out recursively. If -N is given on a line, svn checkout |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
42 will be called with -N as parameter. |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
43 |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
44 The example above will be converted into the internal form [('.', |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
45 False), ('subdir1', True), ('subdir2', True)] used by the |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
46 treepkg.subversion module. |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
47 """ |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
48 subset = [] |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
49 for line in raw.splitlines(): |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
50 split = shlex.split(line) |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
51 if len(split) < 1: |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
52 # ignore empty lines |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
53 continue |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
54 subdir = split[-1] |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
55 recurse = True |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
56 flags = split[:-1] |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
57 if flags: |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
58 if flags == ["-N"]: |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
59 recurse = False |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
60 else: |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
61 raise ValueError("Only -N is supported as flag, but flags = %r" |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
62 % (flags,)) |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
63 subset.append((subdir, recurse)) |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
64 return subset |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
65 |
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
66 |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
67 packager_desc = [ |
304
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
68 "name", "base_dir", |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
69 ("url", str, ""), |
521
d26642ed6afa
use empty string as default config values instead of None
Bjoern Ricks <bricks@intevation.de>
parents:
516
diff
changeset
|
70 ("svn_url", str, ""), |
321
092925ff75d7
Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents:
306
diff
changeset
|
71 ("svn_subset", convert_subversion_subset, ""), |
306
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
72 ("svn_externals", shlex.split, ""), |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
73 ("rules_url", str, ""), ("packager_class", str, "treepkg.packager"), |
344
f06f707d9fda
merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents:
340
diff
changeset
|
74 ("root_cmd", shlex.split, "sudo"), "builderconfig", |
297
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
75 "deb_email", "deb_fullname", ("deb_build_options", str, ""), |
305
3781e9958eba
Add per-track configuration option version_template used by the
Bernhard Herzog <bh@intevation.de>
parents:
304
diff
changeset
|
76 ("version_template", str, "%(revision)s"), |
299
c32dc72ba979
Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents:
297
diff
changeset
|
77 "pkg_revision_template", ("pkg_basename", str, ""), |
129
ce9f046058b5
Add the handle_dependencies Option for the config file. Extend the test
Bernhard Herzog <bh@intevation.de>
parents:
115
diff
changeset
|
78 ("handle_dependencies", convert_bool), |
258
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
79 ("signing_key_id", str, ""), |
340
a83a78a93fd6
Changed default message templates to the correct types
Andre Heinecke <aheinecke@intevation.de>
parents:
332
diff
changeset
|
80 ("changelog_msg_template", str, "Update to revision %(revision)s"), |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
81 ("branch", str,""), |
401
2db42a2a9db9
add os config statement
Bjoern Ricks <bricks@intevation.de>
parents:
391
diff
changeset
|
82 ("os", str, ""), |
464
5fda6768bef6
Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents:
445
diff
changeset
|
83 ("builder_cls", str, "PBuilder"), |
516
f2de1c162d30
read scm_type and rules_scm_type from config
Bjoern Ricks <bricks@intevation.de>
parents:
513
diff
changeset
|
84 ("status_hook", str, ""), |
f2de1c162d30
read scm_type and rules_scm_type from config
Bjoern Ricks <bricks@intevation.de>
parents:
513
diff
changeset
|
85 ("scm_type", str, "svn"), |
f2de1c162d30
read scm_type and rules_scm_type from config
Bjoern Ricks <bricks@intevation.de>
parents:
513
diff
changeset
|
86 ("rules_scm_type", str, "svn") |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
87 ] |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
88 |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
89 treepkg_desc = [ |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
90 ("check_interval", int), |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
91 "instructions_file", |
389
a690fc689f2f
added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents:
387
diff
changeset
|
92 ("name", str, ""), |
521
d26642ed6afa
use empty string as default config values instead of None
Bjoern Ricks <bricks@intevation.de>
parents:
516
diff
changeset
|
93 ("treepkg_dir", str, ""), |
d26642ed6afa
use empty string as default config values instead of None
Bjoern Ricks <bricks@intevation.de>
parents:
516
diff
changeset
|
94 ("tracks_dir", str, "") |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
95 ] |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
96 |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
97 |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
98 def read_config_section(parser, section, item_desc, defaults=None): |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
99 if defaults is None: |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
100 defaults = dict() |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
101 options = dict() |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
102 for item in item_desc: |
258
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
103 has_default_value = False |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
104 if isinstance(item, tuple): |
258
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
105 key, converter = item[:2] |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
106 if len(item) == 3: |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
107 default_value = item[-1] |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
108 has_default_value = True |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
109 else: |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
110 key = item |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
111 converter = str |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
112 try: |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
113 value = parser.get(section, key, vars=defaults) |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
114 except NoOptionError: |
258
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
115 if has_default_value: |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
116 value = default_value |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
117 else: |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
118 print >>sys.stderr, "Missing option %r in section %r" \ |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
119 % (key, section) |
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
120 sys.exit(1) |
513
3e08d6546d52
set option value to None and not "None"
Bjoern Ricks <bricks@intevation.de>
parents:
511
diff
changeset
|
121 if value is None: |
3e08d6546d52
set option value to None and not "None"
Bjoern Ricks <bricks@intevation.de>
parents:
511
diff
changeset
|
122 options[key] = value |
3e08d6546d52
set option value to None and not "None"
Bjoern Ricks <bricks@intevation.de>
parents:
511
diff
changeset
|
123 else: |
3e08d6546d52
set option value to None and not "None"
Bjoern Ricks <bricks@intevation.de>
parents:
511
diff
changeset
|
124 options[key] = converter(value) |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
125 return options |
0 | 126 |
127 | |
128 def read_config(filename): | |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
129 """Reads the tree packager configuration from the file given by filename. |
0 | 130 |
115 | 131 The function returns a tuple with a dict ('treepkg') and a list of |
132 dicts ('packagers'). The treepkg dict contains the main | |
133 configuration of the tree packager. The packagers list contains one | |
134 dict with the configuratiin for each packager. | |
0 | 135 """ |
391
89ecca5d262e
check if config file exists to get usefull error output
Bjoern Ricks <bricks@intevation.de>
parents:
389
diff
changeset
|
136 if not os.path.exists(filename): |
89ecca5d262e
check if config file exists to get usefull error output
Bjoern Ricks <bricks@intevation.de>
parents:
389
diff
changeset
|
137 print >>sys.stderr, "Config file %s does not exist" % filename |
89ecca5d262e
check if config file exists to get usefull error output
Bjoern Ricks <bricks@intevation.de>
parents:
389
diff
changeset
|
138 sys.exit(2) |
258
bb98e728f25b
Allow default values for individual options to be passed to read_config_section.
Bernhard Herzog <bh@intevation.de>
parents:
234
diff
changeset
|
139 parser = SafeConfigParser() |
0 | 140 parser.read([filename]) |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
141 |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
142 # extract packager configurations |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
143 packagers = [] |
0 | 144 for section in parser.sections(): |
145 if section.startswith("pkg_"): | |
114
02c261e4443f
Extend treepkg.readconfig.read_config:
Bernhard Herzog <bh@intevation.de>
parents:
93
diff
changeset
|
146 vars = dict(name=section[4:]) |
445
e049599fde1a
Default to treepkg.packager if no packager class is given
Andre Heinecke <aheinecke@intevation.de>
parents:
401
diff
changeset
|
147 try: |
e049599fde1a
Default to treepkg.packager if no packager class is given
Andre Heinecke <aheinecke@intevation.de>
parents:
401
diff
changeset
|
148 packager_class = parser.get(section, "packager_class", |
e049599fde1a
Default to treepkg.packager if no packager class is given
Andre Heinecke <aheinecke@intevation.de>
parents:
401
diff
changeset
|
149 vars=vars) |
e049599fde1a
Default to treepkg.packager if no packager class is given
Andre Heinecke <aheinecke@intevation.de>
parents:
401
diff
changeset
|
150 except NoOptionError: |
e049599fde1a
Default to treepkg.packager if no packager class is given
Andre Heinecke <aheinecke@intevation.de>
parents:
401
diff
changeset
|
151 packager_class = "treepkg.packager" |
114
02c261e4443f
Extend treepkg.readconfig.read_config:
Bernhard Herzog <bh@intevation.de>
parents:
93
diff
changeset
|
152 module = packager.import_packager_module(packager_class) |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
47
diff
changeset
|
153 desc = packager_desc + module.PackageTrack.extra_config_desc |
389
a690fc689f2f
added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents:
387
diff
changeset
|
154 packager_options = read_config_section(parser, section, desc, |
a690fc689f2f
added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents:
387
diff
changeset
|
155 defaults=vars) |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
156 if not packager_options.get("url") and \ |
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
464
diff
changeset
|
157 not packager_options.get("svn_url"): |
332
e0e99b71932b
Added check in readconfig if either a git_url or a svn_url is provided
Andre Heinecke <aheinecke@intevation.de>
parents:
321
diff
changeset
|
158 print >>sys.stderr, "Missing repository URL in section %r" \ |
e0e99b71932b
Added check in readconfig if either a git_url or a svn_url is provided
Andre Heinecke <aheinecke@intevation.de>
parents:
321
diff
changeset
|
159 % (section) |
e0e99b71932b
Added check in readconfig if either a git_url or a svn_url is provided
Andre Heinecke <aheinecke@intevation.de>
parents:
321
diff
changeset
|
160 sys.exit(1) |
389
a690fc689f2f
added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents:
387
diff
changeset
|
161 packagers.append(packager_options) |
0 | 162 |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
163 # main config |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
164 treepkg = read_config_section(parser, "treepkg", treepkg_desc) |
0 | 165 |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
166 return treepkg, packagers |
0 | 167 |
168 | |
169 if __name__ == "__main__": | |
2
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
170 import pprint |
e6a9f4037f68
readconfig.py is smarter now about conversions and supports shlex
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
171 print pprint.pprint(read_config(sys.argv[1])) |