r121 - branches/rewrite/src
Nat Budin
partial-mirror-devel@lists.alioth.debian.org
Thu, 01 Jul 2004 20:45:51 -0600
Author: natbudin-guest
Date: Thu Jul 1 20:45:50 2004
New Revision: 121
Modified:
branches/rewrite/src/Config.py
Log:
Fleshed out Config a bit.
Modified: branches/rewrite/src/Config.py
==============================================================================
--- branches/rewrite/src/Config.py (original)
+++ branches/rewrite/src/Config.py Thu Jul 1 20:45:50 2004
@@ -1,5 +1,5 @@
# debpartial-mirror - partial debian mirror package tool
-# (c) 2004 Otavio Salvador <otavio@debian.org>
+# (c) 2004 Otavio Salvador <otavio@debian.org>, Nat Budin <natb@brandeis.edu>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -57,7 +57,28 @@
error.msg("ERROR: [%s] is not allowed in default section of configuration file." % item)
exit(1)
self['default'][item] = value
-
+
+ for section in conf.sections():
+ self[section] = {}
+ for item, value in conf.items(section):
+ if item not in allowed_in_backend:
+ error.msg("ERROR: [%s] is not allowed in a backend section of a config file (it was found in [%s])." % (item, section))
+ exit(1)
+ self[section][item] = value
+
+ def getValue(self, section, key):
+ # get a config value for a certain section. if it's not specified,
+ # fall back to DEFAULT
+ if not self.has_key(section):
+ error.msg("ERROR: no config section called [%s]." % section)
+ exit(1)
+ if self[section].has_key(key):
+ return self[section][key]
+ if not self['default'].has_key(key):
+ error.msg("ERROR: [%s] is not present in section [%s] or the default section of config file." % (key, section)
+ exit(1)
+ return self['default'][key]
+
def dump(self):
print 'mirror_dir =', self.mirror_dir
print 'architectures =', self.architectures