Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/overlord:master commit in: overlord/
Date: Mon, 07 Feb 2011 03:10:20
Message-Id: 50fc5d0e88f000b775d2e67c24d5d6728833fdbc.dol-sen@gentoo
1 commit: 50fc5d0e88f000b775d2e67c24d5d6728833fdbc
2 Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Sun Feb 6 23:34:36 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sun Feb 6 23:34:36 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/overlord.git;a=commit;h=50fc5d0e
7
8 add the ability to plugin repository definition xml files without editing the config file
9
10 ---
11 overlord/config.py | 37 +++++++++++++++++++++++++++++++------
12 1 files changed, 31 insertions(+), 6 deletions(-)
13
14 diff --git a/overlord/config.py b/overlord/config.py
15 index 4caf83c..884fc58 100644
16 --- a/overlord/config.py
17 +++ b/overlord/config.py
18 @@ -28,6 +28,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
19 #-------------------------------------------------------------------------------
20
21 import sys, ConfigParser
22 +import os
23
24 from optparse import OptionParser, OptionGroup
25 from overlord.debug import OUT
26 @@ -44,6 +45,28 @@ _USAGE = """
27 overlord -f [-o URL]
28 overlord (-l|-L|-S)"""
29
30 +
31 +def read_config(config=None, defaults=None):
32 + """reads the config file defined in defaults['config']
33 + and updates the config
34 +
35 + @param config: ConfigParser.ConfigParser(self.defaults) instance
36 + @param defaults: dict
37 + @modifies config['MAIN']['overlays']
38 + """
39 + config.read(defaults['config'])
40 + if config.get('MAIN', 'overlay_defs'):
41 + filelist = os.listdir(config.get('MAIN', 'overlay_defs'))
42 + filelist = [f for f in filelist if f.endswith('.xml')]
43 + overlays = set(config.get('MAIN', 'overlays').split('\n'))
44 + for _file in filelist:
45 + path = os.path.join(config.get('MAIN', 'overlay_defs'), _file)
46 + if os.path.isfile(path):
47 + overlays.update(["file://" + path])
48 + config.set('MAIN', 'overlays', '\n'.join(overlays))
49 +
50 +
51 +
52 class BareConfig(object):
53 '''Handles the configuration only.'''
54
55 @@ -68,7 +91,8 @@ class BareConfig(object):
56 'nocheck' : 'yes',
57 'proxy' : '',
58 'umask' : '0022',
59 - 'overlays' :
60 + 'overlays' : '',
61 + 'overlay_defs': '/etc/overlord/overlays'
62 'http://www.gentoo.org/proj/en/overlays/repositories.xml',
63 'bzr_command': '/usr/bin/bzr',
64 'cvs_command': '/usr/bin/cvs',
65 @@ -318,7 +342,7 @@ class ArgsParser(object):
66 #-----------------------------------------------------------------
67 # Debug Options
68
69 - self.output.cli_opts(self.parser)
70 + #self.output.cli_opts(self.parser)
71
72 # Parse the command line first since we need to get the config
73 # file option.
74 @@ -333,7 +357,7 @@ class ArgsParser(object):
75 % ', '.join(('"%s"' % e) for e in remain_args[1:]))
76
77 # handle debugging
78 - self.output.cli_handle(self.options)
79 + #self.output.cli_handle(self.options)
80
81 # add output to the options
82 self.options.__dict__['output'] = self.output
83 @@ -351,7 +375,7 @@ class ArgsParser(object):
84 if not self.options.__dict__['config'] is None:
85 self.defaults['config'] = self.options.__dict__['config']
86
87 - self.output.debug('Got config file at ' + self.defaults['config'], 8)
88 + #self.output.debug('Got config file at ' + self.defaults['config'], 8)
89
90 # Now parse the config file
91 self.config = ConfigParser.ConfigParser(self.defaults)
92 @@ -366,9 +390,9 @@ class ArgsParser(object):
93 self.output.set_info_level(int(self['quietness']))
94 self.output.set_warn_level(int(self['quietness']))
95
96 - self.output.debug('Reading config file at ' + self.defaults['config'], 8)
97 + #self.output.debug('Reading config file at ' + self.defaults['config'], 8)
98
99 - self.config.read(self.defaults['config'])
100 + read_config(self.config, self.defaults)
101
102 def __getitem__(self, key):
103
104 @@ -407,6 +431,7 @@ class ArgsParser(object):
105
106 return None
107
108 +
109 def keys(self):
110 '''Special handler for the configuration keys.'''