Python configuration file generator

I want to use Python to create a configuration file generator. My rough idea is to feed input of template files and some XML files with real settings. Then use the program to create real configuration files.

Example:

[template file]
server_IP = %serverip%
server_name = %servername%


[XML file]
<serverinfo>
<server ip="x.x.x.x" name="host1" />
<server ip="x.x.x.x" name="host2" />
</serverinfo>

and then get the output configuration file like this

[server.ini]

[server1]
server_IP = x.x.x.x
server_name = host1

[server2]
server_IP = x.x.x.x
server_name = host2

I had a few questions:

  • Is there any open source configuration generator program? (which could be a keyword), I wonder if there is anything in the project to add / change.

  • Does Python have a good XML parser?

  • XML ? Excel, , . , .

, . !

EDIT: ini . .

  • ip/hostname , , XML . ? (Excel ).

  • ini , , ( Excel - ), ini .

+3
5

ConfigObj . / .

+3

, .

Python XML xml, (, , ) ElementTree. .

xml , . , /, . , ini-style , python .

+3

xml . - . , .

+1

minidom. , , .

+1

You need a template engine, look string.Template

+1
source

Source: https://habr.com/ru/post/1750389/


All Articles