Repository navigation
Conversation
…ionary recursively and replacing text to avoid edge cases which produce invalid yaml or json strings. Also raise a warning if an argument containts {...} text
…onfiguration manager.
|
@JeanLucPons It worked with numbers |
|
@kparasch It would be good to add a section to the tutorials in the documentation on how to use it. |
A how-to guide is likely also needed. |
|
I didn't look too much into templates, but for me, one of the features should be to generate a full config from a template. I personally find that reading a plain config, without template syntax, is easier. But generating a config is easier with a template :) All I'd like is a utility function that spits out a full config (or even Accelerator.save(yamlfile) ) could be a desired feature. |
I think that utility tool is the one @simoneliuzzo has started on in: https://github.com/python-accelerator-middle-layer/configuration-generator. Personally I think implementing |
Implements a Template category in accelerator that allows generation of devices from templates. Uses a "template resolver" to generate from templates.
The template class uses the standard python string ".format" function to replace text and generate the template.The template class stores an expanded template dictionary, which is registered when loading a file with
JSONLoader.loadandYAMLLoader.load. When the template resolver is found (e.g.${template:SHI,SHI,01}), it replaces the parameters walking through the config dictionary and usingstr.replace.example config with template:
The implementation adds:
TemplateManagerto store definitions, validate argument counts, and generate independent configuration structures through recursive string substitution.${template:...}resolver that generates the configuration and passes it through normal expansion, supporting nested templates, file references, and environment variables.The
LoadContext(which is passed to the resolvers) is extended to hold:expandfunction used by theConfigLoader, so that the resolver can expand files found inside the template.TemplateManager.Will close issue #443