Skip to main content

Hierarchical Paths

% start main % start synopsis

MoaT Paths are immutable sequences that can be represented as dot-separated or slash-separated strings, with special encoding for various data types.

MoaT paths are typically entered and displayed with dots as separators and colon as "special" markers. For example, ext:1.set is a three-element path consisting of two strings with an integer in between.

There's a secondary representation that uses slashes (ext/:1/set) for interfacing with the file system or MQTT.

See pydoc moat.lib.path.Path for details.

The MoaT ecosystem uses Path objects as hierarchical accessors for objects and data.

% end synopsis

Usage

Creating paths

from moat.lib.path import Path, P

# Create paths from elements
path = Path()  # empty path

path = P("foo.bar.baz")  # dot notation
assert path == Path.build(("foo", "bar", "baz"))  # assemble from tuples, lists etc.

# Create from various types
path = Path.build(("config", 42, True))  # Mixed types
assert path == P("config:x2a:t")  # config, 0x2a (42), True

Path representation

Paths can be represented in two forms:

Dot notation: Elements separated by dots

path = P("foo.bar.baz")
str(path)  # "foo.bar.baz"

Slash notation: Elements separated by slashes

path = P("foo.bar.baz")
path.slash  # "foo/bar/baz"

Special codes

MoaT paths support non-string path elements. The most common are:

# Inline escapes (within an element):
#   ::  escapes : colon
#   :.  escapes . dot
#   :_  escapes   space
#   :|  escapes / slash

# Type prefixes (start a new element):
#   :t   True
#   :f   False
#   :e   empty string
#   :n   None
#   :42  Simple integer
#   :xAB Hex integer (0xAB)
#   :b01 Binary integer (0b01)
#   :yAB Bytestring, hex encoding
#   :sAB Bytestring, base64 encoding

path = P("config:x2a:t")  # Represents ("config", 42, True)

Path operations

from moat.lib.path import Path

path1 = P("foo.bar")
path2 = P("baz.qux")

# Concatenation
combined = path1 + path2  # Path("foo", "bar", "baz", "qux")

# Element access
path1[0]  # "foo"
path1[-1]  # "bar"

# Slicing
path = Path("a.b.c.d")
path[1:3]  # ("b", "c")

# Length
len(path)  # 4

# Iteration
for elem in path:
    print(elem)

# Appending single element
path = path / "new"  # a.b.c.d.new

% end main

Serialization

MoaT paths integrate with serialization formats:

  • YAML: Use a !P prefix for Path objects (dot notation)
  • CBOR: List marked with tag 39 ("Identifier")
  • Msgpack: extension 3 encapsulates path elements

Metadata

Release files for moat-lib-path 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-lib-path 0.4.4
File Size Uploaded Provenance Actions
moat_lib_path-0.4.4.tar.gz 16.9 kB Without provenance Details for moat_lib_path-0.4.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moat-lib-path 0.4.4
File Interpreter ABI Platform Actions
moat_lib_path-0.4.4-py3-none-any.whl Python 3 none any Details for moat_lib_path-0.4.4-py3-none-any.whl

Total release size: 31.3 kB

Release files / moat_lib_path-0.4.4.tar.gz

Download URL moat_lib_path-0.4.4.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
66c18aefb77652b5e12c6415fd1bc129c79e27aa519f7a1f71a8f082b224a288
BLAKE2b-256 checksum
How to use checksums
78d61d60dd22cbcdacd67401d9005c861d93291598aeb747d6c04afae6409838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / moat_lib_path-0.4.4-py3-none-any.whl

Download URL moat_lib_path-0.4.4-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d284ced6301e7e6f6112158a3586392f5abebd58332d63144b5bd84b336b5983
BLAKE2b-256 checksum
How to use checksums
d67f6edcd7fd930771e2c70d57c5ebac2fdab871c9e6a6508a75f53e9bdde71f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for moat-lib-path 0.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page