From 308f68f98b01d9980790816d3a4bf64d0008786b Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 9 Dec 2012 19:23:51 -0800 Subject: [PATCH] hyphenate the config file variables, make config handling work. --- etc/gkeys.conf | 23 +++++++++++++++++------ gkeys/config.py | 33 +++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/etc/gkeys.conf b/etc/gkeys.conf index 6b7c929..de39db5 100644 --- a/etc/gkeys.conf +++ b/etc/gkeys.conf @@ -4,24 +4,35 @@ [MAIN] # keysdir: base directory to store the binary keyrings and data -keysdir: /home/brian/gpg-test +keys-dir: /var/lib/gentoo + # devkeydir: the directory where the gentoo developer keys # will be stored. -devkeydir: %(keysdir)s/devs +dev-keydir: %(keysdir)s/devs + # releaskeydir: the directory where the official release media keys # will be stored. -releasekeydir: %(keysdir)s/release +release-keydir: %(keysdir)s/release + + +# overlayskeydir: the directory where the overlay keys +# will be stored. +overlays-keydir: %(keysdir)s/overlays + # knownkeysfile: txt file to hold a cache of the # installed (name, keyid, fingerprint) keys -knownkeysfile: %(keysdir)s/knownkeys +known-keysfile: %(keysdir)s/knownkeys + # releaseseedfile: txt file of one tuple of (name, keyid, fingerprint) # entry per line -releaseseedfile: /etc/gentoo-keys/release.seeds +release-seedfile: /etc/gentoo-keys/release.seeds + # devseedfile: txt file of one tuple of (name, keyid, fingerprint) # entry per line -devseedfile: /etc/gentoo-keys/developer.seeds +dev-seedfile: /etc/gentoo-keys/developer.seeds + diff --git a/gkeys/config.py b/gkeys/config.py index a15ec55..3695242 100644 --- a/gkeys/config.py +++ b/gkeys/config.py @@ -34,7 +34,7 @@ class GKeysConfig(GPGConfig): """ Configuration superclass which holds our gentoo-keys config settings for pygpg """ - def __init__ (self, config=None, root=None): + def __init__ (self, config=None, root=None, read_configfile=False): """ Class initialiser """ GPGConfig.__init__(self) @@ -46,18 +46,18 @@ class GKeysConfig(GPGConfig): self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gentoo-keys']) self.defaults['config'] = '%(configdir)s/gkeys.conf' self.configparser = None - - # read our config file overrides - self.read_config() + if read_configfile: + self.read_config() def _add_gkey_defaults(self): - self.defaults['keysdir'] = path([self.root, EPREFIX, '/var/gentoo/gkeys']) - self.defaults['devkeydir'] = '%(keysdir)s/devs' - self.defaults['releasekeydir'] = '%(keysdir)s/release' - self.defaults['knownkeysfile'] = '%(keysdir)s/knownkeys' - self.fedualts['releaseseedfile'] = '%(configdir)s/release.seeds' - self.fedualts['devseedfile'] = '%(configdir)s/developer.seeds' + self.defaults['key-sdir'] = path([self.root, EPREFIX, '/var/gentoo/gkeys']) + self.defaults['dev-keydir'] = '%(keysdir)s/devs' + self.defaults['release-keydir'] = '%(keysdir)s/release' + self.defaults['overlays-keydir'] = '%(keysdir)s/overlays' + self.defaults['known-keysfile'] = '%(keysdir)s/knownkeys' + self.defaults['release-seedfile'] = '%(configdir)s/release.seeds' + self.defaults['dev-seedfile'] = '%(configdir)s/developer.seeds' @@ -73,11 +73,20 @@ class GKeysConfig(GPGConfig): self.configparser.add_section('MAIN') self.configparser.read(defaults['config']) + + def get_key(self, key): + return self._get_(key) + + def _get_(self, key): if self.configparser and self.configparser.has_option('MAIN', key): return self.configparser.get('MAIN', key) - else: - super('GKeysConfig', self)._get_(key) + elif key in self.options: + return self.options[key] + elif key in self.defaults: + return self.defaults[key] + logger.error("GKeysConfig: _get_(); didn't find :", key) + return None class GKEY(namedtuple('GKEY', ['name', 'keyid', 'longkeyid', -- 2.26.2