when no cfg file is there, create it
This commit is contained in:
8
utils.py
8
utils.py
@ -56,10 +56,14 @@ class BoxInfo:
|
||||
|
||||
def read_config(self, section=None):
|
||||
cfgfiles = glob(self.CFGPATH % ('*', self.id))
|
||||
if len(cfgfiles) != 1:
|
||||
raise ValueError('there must be one and only one single cfgfile %r' % cfgfiles)
|
||||
if len(cfgfiles) > 1:
|
||||
raise ValueError('ambiguous cfgfile: %r' % cfgfiles)
|
||||
if section and not cfgfiles:
|
||||
raise ValueError('no cfg file found for %s' % self.id)
|
||||
if cfgfiles:
|
||||
self.cfgfile = cfgfiles[0]
|
||||
else:
|
||||
return {}
|
||||
parser = ConfigParser()
|
||||
parser.read(self.cfgfile)
|
||||
if section:
|
||||
|
Reference in New Issue
Block a user