hisscl


Namehisscl JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryA Python HCL parser
upload_time2024-11-10 20:17:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords config configuration hashicorp hcl parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HissCL

A [HashiCorp Config Language](https://github.com/hashicorp/hcl) parser for Python

## Usage

For most simple use-cases, you can use the `load*` convenience functions:

`load_file()`:
```python
import hisscl
cfg = hisscl.load_file("config.hcl")
```

`loads()`:
```python
import hisscl
# Use the optional name argument to specify a filename for errors
cfg = hisscl.loads("x = 2 * 4", name='string.hcl')
```

`load()`:
```python
import hisscl
with open('test.hcl', 'r') as fl:
    # Use the optional name argument to specify a filename for errors
    cfg = hisscl.load(fl, name=fl.name)
```

Each `load*` function has an optional `vars: dict[str, Any]` parameter, whose elements are used as variables in your config file. For example, if you have `x = y + 1`, `y` must be defined in `vars`.

For more advanced use-cases, `lexer`, `parser`, `ast`, and `interp` submodules are provided.

## Output Format

The interpreter outputs a python dictionary containing field values and blocks. Blocks are stored in a list of `interp.Block` values. `interp.Block` is a subclass of `dict` with an extra `labels` attribute that can be used to get a list of block labels. For example:

```python
import hisscl
cfg = hisscl.loads('x "y" "z" { a = "b" }')
print(cfg['x'][0].labels) # ['y', 'z']
print(cfg['x'][0]['a']) # b
```

## Features

Currently, this parser supports all HCL features except:

- [For Expressions](https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#for-expressions)
- [Templates](https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#templates)

Support for these features is planned.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hisscl",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "config, configuration, hashicorp, hcl, parser",
    "author": null,
    "author_email": "Elara6331 <elara@elara.ws>",
    "download_url": null,
    "platform": null,
    "description": "# HissCL\n\nA [HashiCorp Config Language](https://github.com/hashicorp/hcl) parser for Python\n\n## Usage\n\nFor most simple use-cases, you can use the `load*` convenience functions:\n\n`load_file()`:\n```python\nimport hisscl\ncfg = hisscl.load_file(\"config.hcl\")\n```\n\n`loads()`:\n```python\nimport hisscl\n# Use the optional name argument to specify a filename for errors\ncfg = hisscl.loads(\"x = 2 * 4\", name='string.hcl')\n```\n\n`load()`:\n```python\nimport hisscl\nwith open('test.hcl', 'r') as fl:\n    # Use the optional name argument to specify a filename for errors\n    cfg = hisscl.load(fl, name=fl.name)\n```\n\nEach `load*` function has an optional `vars: dict[str, Any]` parameter, whose elements are used as variables in your config file. For example, if you have `x = y + 1`, `y` must be defined in `vars`.\n\nFor more advanced use-cases, `lexer`, `parser`, `ast`, and `interp` submodules are provided.\n\n## Output Format\n\nThe interpreter outputs a python dictionary containing field values and blocks. Blocks are stored in a list of `interp.Block` values. `interp.Block` is a subclass of `dict` with an extra `labels` attribute that can be used to get a list of block labels. For example:\n\n```python\nimport hisscl\ncfg = hisscl.loads('x \"y\" \"z\" { a = \"b\" }')\nprint(cfg['x'][0].labels) # ['y', 'z']\nprint(cfg['x'][0]['a']) # b\n```\n\n## Features\n\nCurrently, this parser supports all HCL features except:\n\n- [For Expressions](https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#for-expressions)\n- [Templates](https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#templates)\n\nSupport for these features is planned.",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python HCL parser",
    "version": "0.0.3",
    "project_urls": {
        "GitHub": "https://github.com/Elara6331/hisscl",
        "Repository": "https://gitea.elara.ws/Elara6331/hisscl"
    },
    "split_keywords": [
        "config",
        " configuration",
        " hashicorp",
        " hcl",
        " parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7335c590e7adf7b19c7509b710bc29f8e8842d5ed03674d4a0c4ec7d0633ac8f",
                "md5": "3f9e864262520b7dd38a1fe600656adb",
                "sha256": "88e7adaf83b9829b92b3c8406ba9e43949e0a81ad1fe8ac20bc114244a2ed7e2"
            },
            "downloads": -1,
            "filename": "hisscl-0.0.3-1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f9e864262520b7dd38a1fe600656adb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13787,
            "upload_time": "2024-11-10T20:17:37",
            "upload_time_iso_8601": "2024-11-10T20:17:37.408609Z",
            "url": "https://files.pythonhosted.org/packages/73/35/c590e7adf7b19c7509b710bc29f8e8842d5ed03674d4a0c4ec7d0633ac8f/hisscl-0.0.3-1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-10 20:17:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Elara6331",
    "github_project": "hisscl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hisscl"
}
        
Elapsed time: 0.51161s