I am using Python 3.13.3.
I have configurations like:
[DEFAULT]
machines = machine1 machine2 machine3
foo = bar
[deployment]
[machine1]
tomcat = /home/user/install/tomcat
dcpc = /home/user/install/dcpc
[machine2]
pe = /home/user/install/server
dbloader = /home/user/install/server
reqgen = /home/user/install/server
[machine2]
dcpc = /home/user/install/dcpc
dcpc2 = /home/user/install/dcpc2
dcpc3 = /home/user/install/dcpc3
And I do not know in advance what will be there exactly. I want then to go through each of those machines
, connect to it and check what there is in those directories.
So I have this method:
def get_modules_in_machines(self):
modules_in_machines = list()
machines = self.config["DEFAULT"]["machines"].split()
for machine in machines:
logger.debug(f"Reading config for {machine}")
modules_in_machine = dict(self.config.items(machine, raw=True))
logger.debug(f"Config is: {modules_in_machine}")
modules_in_machines.append((machine, modules_in_machine))
return modules_in_machines
That is NOT supposed to return foo: bar
, but it does return it along the contents of the specified section; why? I thought the raw=True
had to do exactly that: skip values in DEFAULT section.
Thank you very much for your help.