Tools for reading python config files into R + bash
To install the scripts into your ~/bin directory type:
make install
This is not essential, although you need to have pyconfconv.py in your $PATH for pyconfconv.r to work unmodified.
$ pyconfconv.py -h
usage: pyconfconv.py [-h] [-i filename] [-l language] [-s section]
Convert python config files into useful formats.
optional arguments:
-h, --help show this help message and exit
-i filename Source file.
-l language Output language.
-s section Section to output.
If you do not select a section, then section names are used as prefixes for variable names with an underscore separating them.
To use the bash wrapper, simply source pyconfconv.sh with the right arguments, e.g.
#!/usr/bin/env bash
source `which pyconfconv.sh` examples/config.ini hosts
To use the R wrapper, you need to make sure that pyconfconv.py is in your $PATH and, source pyconfconv.r and then eval either pyconfconverts(filename, section) or pyconfconvert(filename) depending on whether you want to pull out a section or not.
#!/usr/bin/env Rscript
source("pyconfconv.r")
eval(parse(text=pyconfconverts("examples/config.ini", "hosts")))
or for the entire file:
#!/usr/bin/env Rscript
source("pyconfconv.r")
eval(parse(text=pyconfconvert("examples/config.ini")))