allow inline comments with '#' in box cfg files

This commit is contained in:
2025-07-08 08:15:52 +02:00
parent 16c58c7bb1
commit df19b1c8a0
3 changed files with 4 additions and 4 deletions

View File

@@ -16,5 +16,5 @@ eth3=192.168.127.254
5900=192.168.2.2:5900
[FRAPPY]
cfg=demo # the cfg file for the frappy server
port=5000 # the port for the frappy server
cfg=demo # config file
port=5000 # port

View File

@@ -49,7 +49,7 @@ all_ports = {}
for file in sorted(cfgdir.glob('*.cfg')):
name = file.stem
all_ports[name] = box_ports = {}
parser = ConfigParser()
parser = ConfigParser(inline_comment_prefixes=('#',))
parser.read(file)
info = {k: dict(parser[k]) for k in parser.sections()}
router = info.get('ROUTER', {})

View File

@@ -123,7 +123,7 @@ class BoxInfo:
self.cfgfile = cfgfiles[0]
else:
return {}
parser = ConfigParser()
parser = ConfigParser(inline_comment_prefixes=('#',))
parser.read(self.cfgfile)
if section:
if section in parser.sections():