hisscl


Namehisscl JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryA Python HCL parser
upload_time2024-11-14 03:01:45
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMPL-2.0
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": "https://files.pythonhosted.org/packages/97/35/312a1eda7f2e4b9ba56f5ac902c9deb45611a35026cc12254e5bcca128c2/hisscl-0.0.4.tar.gz",
    "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": "MPL-2.0",
    "summary": "A Python HCL parser",
    "version": "0.0.4",
    "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": "5280aadf811748b4c6da79d4c293394826521360e99de6e111e2b2e06d318d7e",
                "md5": "29d8ecb861a2e9ea5feac50bf499fd8d",
                "sha256": "fe23b0e8dc0010be0be57e3888dcb52b758dece5be1bc4629c12901e8bd821b0"
            },
            "downloads": -1,
            "filename": "hisscl-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29d8ecb861a2e9ea5feac50bf499fd8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14353,
            "upload_time": "2024-11-14T03:01:43",
            "upload_time_iso_8601": "2024-11-14T03:01:43.675744Z",
            "url": "https://files.pythonhosted.org/packages/52/80/aadf811748b4c6da79d4c293394826521360e99de6e111e2b2e06d318d7e/hisscl-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9735312a1eda7f2e4b9ba56f5ac902c9deb45611a35026cc12254e5bcca128c2",
                "md5": "6f501172905e6b04493757136b70cc38",
                "sha256": "f538fb3ba772cc940c231f7e2ca6b16896c4603a9dbd38bc610ad5cd0e093198"
            },
            "downloads": -1,
            "filename": "hisscl-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "6f501172905e6b04493757136b70cc38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14854,
            "upload_time": "2024-11-14T03:01:45",
            "upload_time_iso_8601": "2024-11-14T03:01:45.391101Z",
            "url": "https://files.pythonhosted.org/packages/97/35/312a1eda7f2e4b9ba56f5ac902c9deb45611a35026cc12254e5bcca128c2/hisscl-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 03:01:45",
    "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: 2.38043s