pathtmpl


Namepathtmpl JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPath Template
upload_time2024-10-20 12:22:28
maintainerNone
docs_urlNone
authorEugen Ciur
requires_python<4.0,>=3.13
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Path Template

## Install

```shell
poetry add pathtmpl
```


## Usage

```python
import uuid
from pathlib import PurePath
from datetime import date as Date
from pathtmpl import DocumentContext, CField, get_evaluated_path


path_tmpl = """
{% if document.cf['Effective Date'] %}
    /home/Tax/{{ document.cf['Effective Date'] | datefmt("%Y") }}.pdf
{% else %}
    /home/Tax/{{ document.id }}.pdf
{% endif %}
"""
custom_fields = [
    CField(name="Total", value=245.02),
    CField(name="Effective Date", value=Date(2024, 12, 23)),
]
doc = DocumentContext(
    id=uuid.uuid4(),
    title="coco",
    custom_fields=custom_fields,
)

ev_path = get_evaluated_path(doc, path_template=path_tmpl)
assert ev_path == PurePath("/home/Tax/2024.pdf")
```

## Tests


```shell
poetry run pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pathtmpl",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.13",
    "maintainer_email": null,
    "keywords": null,
    "author": "Eugen Ciur",
    "author_email": "eugen@papermerge.com",
    "download_url": "https://files.pythonhosted.org/packages/da/bc/15138baea9383257f41052ddcc4c2ab743de614d7696261a2b771e8160eb/pathtmpl-0.1.0.tar.gz",
    "platform": null,
    "description": "# Path Template\n\n## Install\n\n```shell\npoetry add pathtmpl\n```\n\n\n## Usage\n\n```python\nimport uuid\nfrom pathlib import PurePath\nfrom datetime import date as Date\nfrom pathtmpl import DocumentContext, CField, get_evaluated_path\n\n\npath_tmpl = \"\"\"\n{% if document.cf['Effective Date'] %}\n    /home/Tax/{{ document.cf['Effective Date'] | datefmt(\"%Y\") }}.pdf\n{% else %}\n    /home/Tax/{{ document.id }}.pdf\n{% endif %}\n\"\"\"\ncustom_fields = [\n    CField(name=\"Total\", value=245.02),\n    CField(name=\"Effective Date\", value=Date(2024, 12, 23)),\n]\ndoc = DocumentContext(\n    id=uuid.uuid4(),\n    title=\"coco\",\n    custom_fields=custom_fields,\n)\n\nev_path = get_evaluated_path(doc, path_template=path_tmpl)\nassert ev_path == PurePath(\"/home/Tax/2024.pdf\")\n```\n\n## Tests\n\n\n```shell\npoetry run pytest\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Path Template",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1efeb95b7fa7bddefa32ed29b1216c8cb6bbbdcf3f2eb63f47c0a493503c52fb",
                "md5": "27fa9868ae5c766372563c0fcd3baf3b",
                "sha256": "da4fe82752e21c9c3b9321aed608d20abb3bd81591a260b2cae023e31eab56e9"
            },
            "downloads": -1,
            "filename": "pathtmpl-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "27fa9868ae5c766372563c0fcd3baf3b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.13",
            "size": 3409,
            "upload_time": "2024-10-20T12:22:27",
            "upload_time_iso_8601": "2024-10-20T12:22:27.117593Z",
            "url": "https://files.pythonhosted.org/packages/1e/fe/b95b7fa7bddefa32ed29b1216c8cb6bbbdcf3f2eb63f47c0a493503c52fb/pathtmpl-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dabc15138baea9383257f41052ddcc4c2ab743de614d7696261a2b771e8160eb",
                "md5": "b6f6a9781bc3c3a24597c0bb52103944",
                "sha256": "47da73598e2315726ea80f5459ed7b3ec1094a4e079ad6858fb82dfbf8af9c22"
            },
            "downloads": -1,
            "filename": "pathtmpl-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b6f6a9781bc3c3a24597c0bb52103944",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.13",
            "size": 2448,
            "upload_time": "2024-10-20T12:22:28",
            "upload_time_iso_8601": "2024-10-20T12:22:28.630939Z",
            "url": "https://files.pythonhosted.org/packages/da/bc/15138baea9383257f41052ddcc4c2ab743de614d7696261a2b771e8160eb/pathtmpl-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-20 12:22:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pathtmpl"
}
        
Elapsed time: 0.72619s