Closed 4383 closed 5 years ago
How to test it:
$ git clone https://github.com/4383/niet/ -b eval
$ cd niet
$ pipenv shell
$ pip install pbr
$ python setup.py install
$ # observe the samples before
$ cat tests/samples/sample.json
$ cat tests/samples/sample.yaml
$ #test it
$ niet project.list tests/samples/sample.json -f eval
$ niet project.list tests/samples/sample.yaml -f eval
$ # enjoy!
worked after installing in the virtenv: future jmespath PyYAML my example has no nesting so I had to run it like this:
> cat config.yaml
# species database for enrichment with InterMine
mine: "YeastMine"
orgdb: "org.Sc.sgd.db"
threads: 80
pychopper: TRUE
> niet . config.yaml -f eval
mine="YeastMine";orgdb="org.Sc.sgd.db";threads="80";pychopper="True"
# good but not exported
> echo $mine
<nothing>
the final test command
> eval $(niet . config.yaml -f eval)
> echo $mine
YeastMine
I had to add my own eval on top has your eval seems to be volatile and does not export (is this right?)
Thanks for the great addition, I am sure this will be useful to more
Hello @splaisan, thank you for your review :)
worked after installing in the virtenv: future jmespath PyYAML my example has no nesting so I had to run it like this:
> cat config.yaml # species database for enrichment with InterMine mine: "YeastMine" orgdb: "org.Sc.sgd.db" threads: 80 pychopper: TRUE > niet . config.yaml -f eval mine="YeastMine";orgdb="org.Sc.sgd.db";threads="80";pychopper="True" # good but not exported
It's not possible to export persistant environment variables from python. I mean, it's you can set/export environment variables who will be there only during the time of your python process, niet
in our case, but when your process is termined every env vars previously setup was gone too.
echo $mine
``` the final test command
> eval $(niet . config.yaml -f eval) > echo $mine YeastMine
I had to add my own eval on top has your eval seems to be volatile and does not export (is this right?)
You are right you need to eval
the output of niet
to play with it in shell/bash env.
Thanks for the great addition, I am sure this will be useful to more
You are welcome :)
I also added the possibility to generate shell arrays from python lists, another future improvement can be to check and adapt output to specific shell (bash, zsh, ksh, etc...), I guess some minor difference exists between all of them and it can be useful to provide a list of supported shells.
Allow user to eval the output with shell. All the retrieved elements will become strings that can be transformed in shell variables by using the linux eval command.
https://github.com/openuado/niet/issues/48 https://gist.github.com/pkuczynski/8665367
Implement #48