Skip to main content

Path Template

Project description

Path Template

Install

poetry add pathtmpl

Usage

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

poetry run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pathtmpl-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

pathtmpl-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file pathtmpl-0.1.0.tar.gz.

File metadata

  • Download URL: pathtmpl-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for pathtmpl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47da73598e2315726ea80f5459ed7b3ec1094a4e079ad6858fb82dfbf8af9c22
MD5 b6f6a9781bc3c3a24597c0bb52103944
BLAKE2b-256 dabc15138baea9383257f41052ddcc4c2ab743de614d7696261a2b771e8160eb

See more details on using hashes here.

File details

Details for the file pathtmpl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pathtmpl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Linux/6.5.0-1025-azure

File hashes

Hashes for pathtmpl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da4fe82752e21c9c3b9321aed608d20abb3bd81591a260b2cae023e31eab56e9
MD5 27fa9868ae5c766372563c0fcd3baf3b
BLAKE2b-256 1efeb95b7fa7bddefa32ed29b1216c8cb6bbbdcf3f2eb63f47c0a493503c52fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page