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
- Host: GitHub
- URL: https://github.com/owainkenwayucl/pyconfconv
- Owner: owainkenwayucl
- License: mit
- Created: 2016-08-01T16:17:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-01T16:45:51.000Z (almost 10 years ago)
- Last Synced: 2025-07-08T00:13:37.634Z (12 months ago)
- Topics: bash, configuration-file, conversion, python, r
- Language: Python
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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")))
```