moban icon indicating copy to clipboard operation
moban copied to clipboard

Configuration data structure transforms

Open jayvdb opened this issue 7 years ago • 4 comments

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

jayvdb avatar May 29 '18 16:05 jayvdb

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.

chfw avatar Jul 15 '18 08:07 chfw

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

jayvdb avatar Jan 24 '19 05:01 jayvdb

this topic has a lot of tangible values and with this issue resolved, moban will have an edge over other cli commands.

chfw avatar Oct 12 '19 15:10 chfw

a further thought on this: a specific data transformer is required per use case, because input data structure and output data structure varies.

chfw avatar Dec 28 '19 21:12 chfw