template files evaluation in python -


To translate a set of templates into a set of configuration files based on the values ​​taken from a main configuration, Python I am trying to use the file. However, I'm having some problems considering the following example of a template file.

file1.cfg.template

 % (CLIENT1) s% (HOST1) s% (PORT1) d C% (COMPID1) s% (customer2) s% (HOST2) s% (PORT2) s% (COMPID2) s  

This file contains an entry for each customer, there are hundreds of config files in this way and I need to configure each type of config file Do not argue for. Python should be substituted and the config file should be automatically given a set of global values ​​to be read from a main XML config file. However, in the above example, if Client 2 is not present, then how do I delete that line? I hope the Python will generate a config file via something like this:

  os.open ("file1.cfg.template"). Read ()% myhash  

Where there is a hash of configuration parameter from the Mahesh main config file, in which CLIENT2 can not be included at all, in this case it does not have CLIENT2, I want to This file disappears from the file. Is it possible to include some 'IF' block in the file and can the dragon evaluate it?

Thanks for your help, any suggestions are most welcome.

It looks as if you've already passed a simple home-growing templing solution Should you do anything?

  • Other options:

    • / Li>

Comments