An open API service indexing awesome lists of open source software.

https://github.com/owainkenwayucl/pyconfconv

Tools for reading python config files into R + bash
https://github.com/owainkenwayucl/pyconfconv

bash configuration-file conversion python r

Last synced: about 2 months ago
JSON representation

Tools for reading python config files into R + bash

Awesome Lists containing this project

README

          

# pyconfconv
Tools for reading python config files into R + bash

## Usage

To install the scripts into your ~/bin directory type:

```none
make install
```

This is not essential, although you need to have pyconfconv.py in your $PATH for pyconfconv.r to work unmodified.

## At the command-line

```none
$ 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.

## From a bash script

To use the bash wrapper, simply source pyconfconv.sh with the right arguments, e.g.

```bash
#!/usr/bin/env bash

source `which pyconfconv.sh` examples/config.ini hosts
```

## From an R script

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.

```r
#!/usr/bin/env Rscript

source("pyconfconv.r")

eval(parse(text=pyconfconverts("examples/config.ini", "hosts")))
```

or for the entire file:

```r
#!/usr/bin/env Rscript

source("pyconfconv.r")

eval(parse(text=pyconfconvert("examples/config.ini")))
```