HCL configuration parser for python
Project description
pyhcl
=====
Implements a parser for [HCL (HashiCorp Configuration Language)](https://github.com/hashicorp/hcl)
in Python. This implementation aims to be compatible with the original
golang version of the parser.
The grammar and many of the tests/fixtures were copied/ported from the golang
parser into pyhcl.
Installation
============
pip install pyhcl
Usage
=====
This module is intended to be used in mostly the same way that one would use
the json module in python, and load/loads/dumps are implemented.
import hcl
with open('file.hcl', r) as fp:
obj = hcl.load(fp)
Currently the dumps function outputs JSON, and not HCL.
Syntax
======
* Single line comments start with `#` or `//`
* Multi-line comments are wrapped in `/*` and `*/`
* Values are assigned with the syntax `key = value` (whitespace doesn't
matter). The value can be any primitive: a string, number, boolean,
object, or list.
* Strings are double-quoted and can contain any UTF-8 characters.
Example: `"Hello, World"`
* Numbers are assumed to be base 10. If you prefix a number with 0x,
it is treated as a hexadecimal. If it is prefixed with 0, it is
treated as an octal. Numbers can be in scientific notation: "1e10".
* Boolean values: `true`, `false`, `on`, `off`, `yes`, `no`.
* Arrays can be made by wrapping it in `[]`. Example:
`["foo", "bar", 42]`. Arrays can contain primitives
and other arrays, but cannot contain objects. Objects must
use the block syntax shown below.
Objects and nested objects are created using the structure shown below:
```
variable "ami" {
description = "the AMI to use"
}
```
Testing
=======
To run the tests:
cd tests
py.test
Authors
=======
Dustin Spicuzza (dustin@virtualroadside.com)
Note: This project is not associated with Hashicorp
=====
Implements a parser for [HCL (HashiCorp Configuration Language)](https://github.com/hashicorp/hcl)
in Python. This implementation aims to be compatible with the original
golang version of the parser.
The grammar and many of the tests/fixtures were copied/ported from the golang
parser into pyhcl.
Installation
============
pip install pyhcl
Usage
=====
This module is intended to be used in mostly the same way that one would use
the json module in python, and load/loads/dumps are implemented.
import hcl
with open('file.hcl', r) as fp:
obj = hcl.load(fp)
Currently the dumps function outputs JSON, and not HCL.
Syntax
======
* Single line comments start with `#` or `//`
* Multi-line comments are wrapped in `/*` and `*/`
* Values are assigned with the syntax `key = value` (whitespace doesn't
matter). The value can be any primitive: a string, number, boolean,
object, or list.
* Strings are double-quoted and can contain any UTF-8 characters.
Example: `"Hello, World"`
* Numbers are assumed to be base 10. If you prefix a number with 0x,
it is treated as a hexadecimal. If it is prefixed with 0, it is
treated as an octal. Numbers can be in scientific notation: "1e10".
* Boolean values: `true`, `false`, `on`, `off`, `yes`, `no`.
* Arrays can be made by wrapping it in `[]`. Example:
`["foo", "bar", 42]`. Arrays can contain primitives
and other arrays, but cannot contain objects. Objects must
use the block syntax shown below.
Objects and nested objects are created using the structure shown below:
```
variable "ami" {
description = "the AMI to use"
}
```
Testing
=======
To run the tests:
cd tests
py.test
Authors
=======
Dustin Spicuzza (dustin@virtualroadside.com)
Note: This project is not associated with Hashicorp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyhcl-0.1.0.tar.gz
(15.0 kB
view details)
File details
Details for the file pyhcl-0.1.0.tar.gz
.
File metadata
- Download URL: pyhcl-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98e3a316b94e9accfb43e75fc621093e76c2f9d4aa4a24c1a63c6ffe599e6a3a |
|
MD5 | f164e57efa5343887e41e97d5bdf0c33 |
|
BLAKE2b-256 | 12577ca6fa267eb43da93433b3f00e0646557db4b13b7eae990c6be9cb9faa90 |