make 'frappy listcfg' bhave like nicos 'frappy_list()'

This commit is contained in:
l_samenv 2022-07-06 08:45:26 +02:00
parent 0904390dc3
commit e67fa0bc35

View File

@ -49,15 +49,17 @@ class FrappyManager(ServiceManager):
cfgpaths = []
cfgparser = ConfigParser()
cfgparser.optionxform = str
cfgfile = self.env[ins]['FRAPPY_CONFIG_FILE'].replace('<SERV>', 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('<SERV>', 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('<SERV>'):
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():