Skip to main content

Convert Ruby output of older Hiera versions to equivalent Python or JSON data structures

Project description

# hipy

[![Travis CI Build Status](https://travis-ci.org/marthjod/hipy.svg?branch=master)](https://travis-ci.org/marthjod/hipy)
[![Coverage Status](https://coveralls.io/repos/github/marthjod/hipy/badge.svg?branch=master)](https://coveralls.io/github/marthjod/hipy?branch=master)

Convert Ruby output of older Hiera versions to equivalent Python or JSON data structures.

## Usage

```bash
Usage: hipy [OPTIONS]

Convert Hiera output to JSON/Python

Options:
--version Show the version and exit.
--json / --python Format output as JSON/Python (default: JSON)
--debug Show debug output (mainly from parser)
--help Show this message and exit.
```

## Examples

### Standalone CLI script

```bash
$ echo nil | hipy
null
$ echo nil | hipy --json
null
$ echo nil | hipy --python
None
$ echo nil | hipy --python --debug
In: nil
<Node called "nil" matching "nil">
Out: None
```


For more examples (and possible limitations), cf. the test examples.


### Library

```python
>>> from hipy.parser import HieraOutputParser
>>> parser = HieraOutputParser(text='nil')

>>> parser.get_json()
'null'

>>> parser.get_python() is None
True

>>> parser = HieraOutputParser(text='nil', debug=True)
<Node called "nil" matching "nil">
```

## Tests

### tox

```
pip install tox
tox
```

### manually

```
pip install -r test-requirements.txt
nosetests -c nose.cfg
```

## Installation

### PyPI

`pip install hipy`

### Locally

Run `python setup.py install`.

### [PEX](https://pex.readthedocs.io/)

```bash
virtualenv venv
source venv/bin/activate
pip install hipy pex

pex -r <(pip freeze) -c hipy -o hipy.pex

deactivate
mv hipy.pex /tmp
cd /tmp
echo '{"a"=>6}' | ./hipy.pex --python
{u'a': 6}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hipy-0.12.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file hipy-0.12.tar.gz.

File metadata

  • Download URL: hipy-0.12.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hipy-0.12.tar.gz
Algorithm Hash digest
SHA256 331a23b166de1c4d5694593f6237e971e26b8d9115ee832bce1ac7ce85b7580f
MD5 ff45e292b593fd483b313081438b0576
BLAKE2b-256 a9d9c3e2274016f6f6b605e29180f6e03a34490de3bf1b4e8e5b25f8cf5d4c1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page