<commit_before>pyhcl
=====

|Build Status|

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. All releases are tested with Python 2.7, 3.2, 3.3,
and 3.4. 

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.

Convert HCL to JSON
-------------------

pyhcl comes with a script that you can use to easily convert HCL to JSON,
similar to the json.tool that comes with python::

	hcltool INFILE [OUTFILE]
	
Structure Validation
--------------------

Similar to JSON, the output of parsing HCL is a python dictionary with
no defined structure. The golang library for HCL implements support for
parsing HCL according to defined objects, but this implementation does
not currently support such constructs.

Instead, I recommend that you use tools designed to validate JSON, such
as the `schematics <https://pypi.python.org/pypi/schematics>` library. 

Syntax
======

-  Single line comments start with ``#`` or ``//``<commit_msg>Fix link in README<commit_after>pyhcl
=====

|Build Status|

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. All releases are tested with Python 2.7, 3.2, 3.3,
and 3.4. 

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.

Convert HCL to JSON
-------------------

pyhcl comes with a script that you can use to easily convert HCL to JSON,
similar to the json.tool that comes with python::

	hcltool INFILE [OUTFILE]
	
Structure Validation
--------------------

Similar to JSON, the output of parsing HCL is a python dictionary with
no defined structure. The golang library for HCL implements support for
parsing HCL according to defined objects, but this implementation does
not currently support such constructs.

Instead, I recommend that you use tools designed to validate JSON, such
as the `schematics <https://pypi.python.org/pypi/schematics>`_ library. 

Syntax
======

-  Single line comments start with ``#`` or ``//``
{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.005427408412483039, 'mean_word_length': 3.495426829268293, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5844034', 'n_tokens_mistral': 874, 'n_tokens_neox': 809, 'n_words': 397}