- optparser.add_option('-c', '--config', dest='configfile',
- default='/etc/hippotat/config')
+ re = regexp.compile('#.*')
+ cfg.read_string(re.sub('', defcfg))
+ need_defcfg = True
+
+ def readconfig(pathname, mandatory=True):
+ def log(m, p=pathname):
+ if not DBG.CONFIG in debug_set: return
+ print('DBG.CONFIG: %s: %s' % (m, pathname))
+
+ try:
+ files = os.listdir(pathname)
+
+ except FileNotFoundError:
+ if mandatory: raise
+ log('skipped')
+ return
+
+ except NotADirectoryError:
+ cfg.read(pathname)
+ log('read file')
+ return
+
+ # is a directory
+ log('directory')
+ re = regexp.compile('[^-A-Za-z0-9_]')
+ for f in os.listdir(cdir):
+ if re.search(f): continue
+ subpath = pathname + '/' + f
+ try:
+ os.stat(subpath)
+ except FileNotFoundError:
+ log('entry skipped', subpath)
+ continue
+ cfg.read(subpath)
+ log('entry read', subpath)
+
+ def oc_config(od,os, value, op):
+ nonlocal need_defcfg
+ need_defcfg = False
+ readconfig(value)