moban
moban copied to clipboard
Configuration data structure transforms
jinja is a horrible language to transform data structures before they are used by a block in another template.
I tried to fill extra_dependencies using jinja set. {% set extra_dependencies = ... %} does work, but it requires the exact same structure.
I couldnt transform existing data from a different structure.
Anyway, there could be a better way..
https://github.com/coala/coala-bears/blob/master/.moban.yaml overrides https://github.com/coala/coala-bears/blob/master/bear-requirements.yaml which has
pip_requirements:
HTTPolice:
version: ~=0.5.2
aenum:
version: ~=2.0.8
I want it to look like
extra_dependencies:
- all:
- HTTPolice~=0.5.2
- aenum~=2.0.8
One way to do this is to incorporate a transform system like https://github.com/dreftymac/dynamic.yaml
Another is https://github.com/moremoban/moban/issues/23
I assume the same problem occurs in reverse. e.g. If I have configuration data in format
a:
- b: z
c: y
d: x
But a template supports multiple values, and thus wants it in a structure like
a:
b:
- z
c:
- y
d:
- x
I suppose two filters are needed.
For now, I have not thought about moban file import. Configuration file override and template override are in place.
one feasible and very generic approach is to have a yaml -> yaml target which uses jinja to do the transform, and load the generated yaml. I.e. https://github.com/moremoban/moban/issues/127
this topic has a lot of tangible values and with this issue resolved, moban will have an edge over other cli commands.
a further thought on this: a specific data transformer is required per use case, because input data structure and output data structure varies.