dipl


Namedipl JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryPython reader and parser module for DIP language
upload_time2023-11-15 14:17:32
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements pytest numpy pandas h5py matplotlib sphinx-rtd-theme toml reportlab beautifulsoup4 scinumtools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DIPL

This module is a quick reading/parsing tool for Dimensional Input Parameter Language (DIP) that is a part of larger [scinumtools](https://github.com/vrtulka23/scinumtools) project.
For more information about DIP, please visit its official [documentation](https://vrtulka23.github.io/scinumtools/dip/index.html).
More functionality can be reqested in [GitHub Issues](https://github.com/vrtulka23/dipl/issues).

## Reading DIP code

Loading DIP code from a string is straightforward.

``` python 
>>> import dipl
>>>
>>> text = """
>>> width float = 23.34 cm
>>> age int = 23 yr
>>>   !tags ["body"]
>>> """
>>> dipl.load(text)
{
  'width': (23.34, 'cm'),
  'age': (23, 'yr')
}
```

It is also possible to change data output format, 

``` python
>>> from dipl import Format
>>> dipl.load(text, Format.VALUE)
{
  'width': 23.34,
  'age': 23,
}
```

or to select only requested nodes using query, or tags:

``` python
>>> dipl.load(text, query="width")
{
  'width': (23.34, 'cm'),
}
>>> dipl.load(text, tags=["body"])
{
  'age': (23, 'yr'),
}
```

## Parsing DIP code

Python dictionaries can be parsed into DIP code, provided that they have a proper structure.
An example parsing is shown below.

``` python
>>> import dipl
>>> import numpy as np
>>> from scinumtools.units import Quatity
>>>
>>> data = {
>>>     'body': {
>>>         'width': Quantity(172.34, 'cm'),
>>>         'age': (23, 'yr'),
>>>     },
>>>     'married': True,
>>>     'name': "John",
>>>     'kids': ["Alice","Williams"],
>>>     'lucky_numbers': np.array([23, 34, 5]),
>>> }
>>> dipl.dump(data)
body
  width float = 172.34 cm
  age int = 23 yr
married bool = true
name str = "John"
kids str[2] = ["Alice","Williams"]
lucky_numbers int[3] = [23,34,5]
```
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dipl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Ondrej Pego Jaura <vrtulka23@pm.me>",
    "download_url": "https://files.pythonhosted.org/packages/82/e5/4296ce4b5f9208922cbe5220b4ddae4629847578ae18efe0b0467c217e88/dipl-1.1.0.tar.gz",
    "platform": null,
    "description": "# DIPL\n\nThis module is a quick reading/parsing tool for Dimensional Input Parameter Language (DIP) that is a part of larger [scinumtools](https://github.com/vrtulka23/scinumtools) project.\nFor more information about DIP, please visit its official [documentation](https://vrtulka23.github.io/scinumtools/dip/index.html).\nMore functionality can be reqested in [GitHub Issues](https://github.com/vrtulka23/dipl/issues).\n\n## Reading DIP code\n\nLoading DIP code from a string is straightforward.\n\n``` python \n>>> import dipl\n>>>\n>>> text = \"\"\"\n>>> width float = 23.34 cm\n>>> age int = 23 yr\n>>>   !tags [\"body\"]\n>>> \"\"\"\n>>> dipl.load(text)\n{\n  'width': (23.34, 'cm'),\n  'age': (23, 'yr')\n}\n```\n\nIt is also possible to change data output format, \n\n``` python\n>>> from dipl import Format\n>>> dipl.load(text, Format.VALUE)\n{\n  'width': 23.34,\n  'age': 23,\n}\n```\n\nor to select only requested nodes using query, or tags:\n\n``` python\n>>> dipl.load(text, query=\"width\")\n{\n  'width': (23.34, 'cm'),\n}\n>>> dipl.load(text, tags=[\"body\"])\n{\n  'age': (23, 'yr'),\n}\n```\n\n## Parsing DIP code\n\nPython dictionaries can be parsed into DIP code, provided that they have a proper structure.\nAn example parsing is shown below.\n\n``` python\n>>> import dipl\n>>> import numpy as np\n>>> from scinumtools.units import Quatity\n>>>\n>>> data = {\n>>>     'body': {\n>>>         'width': Quantity(172.34, 'cm'),\n>>>         'age': (23, 'yr'),\n>>>     },\n>>>     'married': True,\n>>>     'name': \"John\",\n>>>     'kids': [\"Alice\",\"Williams\"],\n>>>     'lucky_numbers': np.array([23, 34, 5]),\n>>> }\n>>> dipl.dump(data)\nbody\n  width float = 172.34 cm\n  age int = 23 yr\nmarried bool = true\nname str = \"John\"\nkids str[2] = [\"Alice\",\"Williams\"]\nlucky_numbers int[3] = [23,34,5]\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python reader and parser module for DIP language",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/vrtulka23/dipl/issues",
        "Homepage": "https://github.com/vrtulka23/dipl"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a57d5135d1958bad2eceb73efbb226a691c6990efc7096656c4b1aeee3c0a8e",
                "md5": "5d678293de8a6d6c8d76abbc6e395163",
                "sha256": "866ce5decdfb499185243a1afefc4c89bc026a6788f49c75307d02f66b913af4"
            },
            "downloads": -1,
            "filename": "dipl-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5d678293de8a6d6c8d76abbc6e395163",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3963,
            "upload_time": "2023-11-15T14:17:30",
            "upload_time_iso_8601": "2023-11-15T14:17:30.604489Z",
            "url": "https://files.pythonhosted.org/packages/4a/57/d5135d1958bad2eceb73efbb226a691c6990efc7096656c4b1aeee3c0a8e/dipl-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82e54296ce4b5f9208922cbe5220b4ddae4629847578ae18efe0b0467c217e88",
                "md5": "8da6619dc66b0349b1acba76f03352cf",
                "sha256": "1d5f90d36bdc2ee289af486266c471d1338a47e1918651ac9afd5422374b85a7"
            },
            "downloads": -1,
            "filename": "dipl-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8da6619dc66b0349b1acba76f03352cf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5605,
            "upload_time": "2023-11-15T14:17:32",
            "upload_time_iso_8601": "2023-11-15T14:17:32.672336Z",
            "url": "https://files.pythonhosted.org/packages/82/e5/4296ce4b5f9208922cbe5220b4ddae4629847578ae18efe0b0467c217e88/dipl-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-15 14:17:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vrtulka23",
    "github_project": "dipl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "h5py",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "sphinx-rtd-theme",
            "specs": []
        },
        {
            "name": "toml",
            "specs": []
        },
        {
            "name": "reportlab",
            "specs": []
        },
        {
            "name": "beautifulsoup4",
            "specs": []
        },
        {
            "name": "scinumtools",
            "specs": []
        }
    ],
    "lcname": "dipl"
}
        
Elapsed time: 0.18932s