teemtee / fmf

Flexible Metadata Format
GNU General Public License v2.0
22 stars 28 forks source link

Tranformation and templating tool #8

Open jscotka opened 6 years ago

jscotka commented 6 years ago

please provide tool what will be able to transform various metadata format like. if you have metadata in one single file, tranform them to files in directory structure, or vice versa, from separate simple files, generate one complex file.

it would also nice to have there some generator what for example generates basic metadata files recursively in directory structure, could work like find . -name "runtest.sh" -print "some strucutre to this directiry." it could create basic test metadata templates

psss commented 6 years ago

I can imagine we could provide a metadata write feature which could do one of the following three levels of the scatteredness (not sure about how we should handle overwriting existing files):

  1. One huge main.fmf file containing the whole metadata tree
  2. One main.fmf file plus additional object.fmf files in a single directory
  3. Separate main.fmf file for each metadata object, directories created as necessary

But what is the exact use case here? Do you expect some big batch changes in metadata? Would something like this be used often? Not sure it is worth to implement it.

jscotka commented 6 years ago

Yep, exactly that is also my idea to use these tree base formats. Would works similar to similar tools like autopep8 what formats your code to better style or helps you for example to transform your mismatch code in one single place to separated files in case you would like to rewrite it to more complex scenarios.

If it is often scenario hard to say. Also some tool what helps you generate metadata from another format can use it. like beakerlib format.

AloisMahdal commented 6 years ago

I think that good rule of thumb is: if you can make use of a tool that generates the meta-data for you automatically, then, well, do you really need the data in the first place? I understand why there could be use case fo some basic templaing, like generating test dir, but what kind of structure to use should be project-specific and wokflow-specific decision.

Ie. it should not be job of fmf but job of some wizard tool that is developed for the given project.

(Just my 2 satoshis.)

psss commented 6 years ago

I think the fmf init use case mentioned in #26 makes a good sense. I can imagine we could even provide fmf init --examples which would populate the initialized metadata tree with a sample skeleton of metadata. Honza, would you be ok to, as the first step, limit scope of this issue for these two features?

jscotka commented 6 years ago

@psss yep, exacly. it is my idea and this transforming could be now forgotten, because noone is directly interested.

And we can use this issue for this init and template generator

Maybe it could be more clever and for example generate this tree structure based on directories and files inside, like I can imagine, that:

.
├── sanity1
│   └── runtest.sh
└── sanity2
    └── script.sh

and tooling like fmf init --element=test="glob.glob('*.sh')[0]" --element=tags="'[sanity]'" can produce main.fmf with content like:

/sanity1
  test: runtest1.sh
  tags: [sanity]
/sanity2
  test: script1.sh
  tags: [sanity]

it is very pythonish and very powerful generator ;-)

psss commented 6 years ago

Interesting example with the glob matching. For the start I would suggest to only support some static skeleton, something similar you get when you call beaker-wizard -yf.

jscotka commented 6 years ago

I've implemented it via https://github.com/psss/fmf/pull/46