From e67fa0bc35cb1e9617cc04107a57ce348c2b9ace Mon Sep 17 00:00:00 2001 From: l_samenv Date: Wed, 6 Jul 2022 08:45:26 +0200 Subject: [PATCH] make 'frappy listcfg' bhave like nicos 'frappy_list()' --- frappyman.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/frappyman.py b/frappyman.py index 4b058be..fb36a48 100644 --- a/frappyman.py +++ b/frappyman.py @@ -49,15 +49,17 @@ class FrappyManager(ServiceManager): cfgpaths = [] cfgparser = ConfigParser() cfgparser.optionxform = str - cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('', service) - cfgparser.read(cfgfile) - try: - section = cfgparser['FRAPPY'] - except KeyError: - if exists(cfgfile): - raise KeyError('%s has no FRAPPY section' % cfgfile) from None - raise FileNotFoundError('%s not found' % cfgfile) from None - for cfgpath in section['confdir'].split(os.pathsep): + cfgfile = self.env[ins].get('FRAPPY_CONFIG_FILE') + confdir = self.env[ins]['FRAPPY_CONFDIR'] + if cfgfile is not None: + cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('', service) + cfgparser.read(cfgfile) + try: + section = cfgparser['FRAPPY'] + except KeyError: + raise ValueError('%s does not exist or has no FRAPPY section' % cfgfile) + confdir = section.get('confdir', confdir) + for cfgpath in confdir.split(os.pathsep): if cfgpath.endswith(''): cfgpaths.append(cfgpath[:-6] + service) else: @@ -146,17 +148,14 @@ class FrappyManager(ServiceManager): return result if by_dir else all_cfg def do_listcfg(self, ins='', service=''): - omit = 'develop' if service: all_cfg = self.all_cfg(ins, service, by_dir=True) - if service == 'develop': - omit = 'NONE' else: all_cfg = {} for service in self.services: all_cfg.update(self.all_cfg(ins, service, by_dir=True)) for cfgdir, cfgs in all_cfg.items(): - if cfgs and not cfgdir.endswith(omit): + if cfgs: print('\n--- %s:\n' % cfgdir) keylen = max(len(k) for k in cfgs) for cfg, desc in cfgs.items():