Skip to main content

This is a library of useful tools for Python.

Project description

PieThorn is a Python utility library that collects several small but reusable tools under one package. It currently includes:

  • collection helpers such as character wrappers, ordered mappings, slice composition utilities, and read-only views

  • filesystem and import helpers for path-aware file handling and module loading

  • lightweight logging and progress counters

  • math helpers for boolean gates, skewed random generation, number-word conversion, timing utilities, and decimal-based equation parsing

  • runtime argument and callable inspection helpers

Project Status

PieThorn is currently marked as alpha-quality software. The public behavior described here is based on the current implementation and test suite.

Requirements

  • Python 3.12 or newer

Installation

Install from PyPI with:

pip install piethorn

To install from a local checkout, first change into the repository root (the directory that contains pyproject.toml), then run:

cd /path/to/PieThorn
pip install .

This installs the package from your working tree as a normal, non-editable installation.

For development work in the same checkout, use an editable install instead:

cd /path/to/PieThorn
pip install -e .

Editable mode keeps the installed package linked to the repository, so changes you make under piethorn/ are picked up without reinstalling after each edit.

Package Overview

piethorn.collections

Character-oriented types, ordered mappings, slice-composition helpers, and immutable views over existing sequences and mappings.

piethorn.filehandle

Filesystem wrappers for building and editing files, JSON persistence helpers, and importer utilities for project-relative path and module resolution.

piethorn.logging

A simple logger plus counter types for progress reporting and parent-child percentage tracking.

piethorn.math

Logic gate helpers, skewed random values, numeric word conversion, timing formatting, and an equation parser/evaluator based on decimal.Decimal.

piethorn.typing

Runtime argument-definition containers and inspect-based callable analysis helpers.

Quick Examples

Collections

from piethorn.collections.char import CharSequence
from piethorn.collections.mapping import Map
from piethorn.collections.views import SequenceView

sequence = CharSequence(["ab", " ", "C"])
mapping = Map(["left", "right"], [1, 2])
view = SequenceView([1, 2, 3, 4], reverse=True, cut=slice(1, 4))

assert str(sequence) == "ab C"
assert mapping["left"] == 1
assert list(view) == [4, 3, 2]

Equation Evaluation

from decimal import Context
from piethorn.math.equation import Equation

eq = Equation("$value$ + $fallback:2$", Context())
assert eq.calculate({"value": 3}) == 5

Logging And Progress

from piethorn.logging.logger import Logger

logger = Logger(debug_level=1)
logger.info("starting")

counter = logger.count("jobs", step=0.5)
counter.add(2)
counter.tick()

File Utilities

from piethorn.filehandle.filehandling import File

root = File("tmp_project", find_children=False)
child = root.create_child("data/example.txt", "hello")
child.write("second line")

Typing Utilities

from piethorn.typing.analyze import analyze

def sample(a, /, b: int, *args, c=3, **kwargs) -> str:
    return "ok"

info = analyze(sample)
assert info.arguments.positional == ("a",)
assert info.arguments.keyword == ("c",)

Documentation

The full documentation source lives in docs/ and includes:

  • getting-started pages

  • narrative guides for each subsystem

  • a layered API reference split into package, module, class, and function pages

If Sphinx is available in your environment, a typical HTML build looks like:

python -m sphinx -b html docs docs/_build/html

Repository Layout

  • piethorn/ contains the package implementation

  • tests/ contains the unit tests

  • docs/ contains the reStructuredText documentation tree

  • pyproject.toml defines the build metadata

Why PieThorn

PieThorn is useful when you want a small grab-bag library of utilities that are more structured than ad-hoc snippets but lighter than pulling in many separate packages for simple tasks.

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

piethorn-0.1.1.tar.gz (108.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piethorn-0.1.1-py3-none-any.whl (74.1 kB view details)

Uploaded Python 3

File details

Details for the file piethorn-0.1.1.tar.gz.

File metadata

  • Download URL: piethorn-0.1.1.tar.gz
  • Upload date:
  • Size: 108.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for piethorn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 814a92d4cec0882e73c201aa22754373610cda9c2f6cbf2ff0a46f38e3221229
MD5 8d23e81ac6748a1e0d4c3e491d49fcc5
BLAKE2b-256 3e26bd0131bf11e85c9f2710f814267b96ed35bbe8c14fd8aa40f78d414c618e

See more details on using hashes here.

Provenance

The following attestation bundles were made for piethorn-0.1.1.tar.gz:

Publisher: live-publish.yml on Officer-Erik-1K-88/PieThorn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file piethorn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: piethorn-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 74.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for piethorn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a87e4f2053a47ce58e41c7d6d854d9ef4505f04aedc56d9ee5f3a1d90a5c7202
MD5 2c02baf486a68b23148f27d67cd75ad0
BLAKE2b-256 9003720030feb0ddf384ae9b0651858701d9fdc88da8e566a13b5f28e1a77755

See more details on using hashes here.

Provenance

The following attestation bundles were made for piethorn-0.1.1-py3-none-any.whl:

Publisher: live-publish.yml on Officer-Erik-1K-88/PieThorn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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