This is a library of useful tools for Python.
Project description
PyThorn 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
PyThorn 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
Install from the repository root:
pip install .
For editable development work:
pip install -e .
Package Overview
- pythorn.collections
Character-oriented types, ordered mappings, slice-composition helpers, and immutable views over existing sequences and mappings.
- pythorn.filehandle
Filesystem wrappers for building and editing files, JSON persistence helpers, and importer utilities for project-relative path and module resolution.
- pythorn.logging
A simple logger plus counter types for progress reporting and parent-child percentage tracking.
- pythorn.math
Logic gate helpers, skewed random values, numeric word conversion, timing formatting, and an equation parser/evaluator based on decimal.Decimal.
- pythorn.typing
Runtime argument-definition containers and inspect-based callable analysis helpers.
Quick Examples
Collections
from pythorn.collections.char import CharSequence
from pythorn.collections.mapping import Map
from pythorn.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 pythorn.math.equation import Equation
eq = Equation("$value$ + $fallback:2$", Context())
assert eq.calculate({"value": 3}) == 5
Logging And Progress
from pythorn.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 pythorn.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 pythorn.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
pythorn/ contains the package implementation
tests/ contains the unit tests
docs/ contains the reStructuredText documentation tree
pyproject.toml defines the build metadata
Why PyThorn
PyThorn 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piethorn-0.1.0.tar.gz.
File metadata
- Download URL: piethorn-0.1.0.tar.gz
- Upload date:
- Size: 115.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa0f1e24dd7597753cc9bf4efed2d26446743dd61b2fef79f9694d96717cf51
|
|
| MD5 |
467c05ae6d165e3fb8a514ee1ab00088
|
|
| BLAKE2b-256 |
8d51d2fdc5c82f39caf9f3a5c485a21134e5af6cc7e11c32f9d4584238c902ee
|
Provenance
The following attestation bundles were made for piethorn-0.1.0.tar.gz:
Publisher:
publish.yml on Officer-Erik-1K-88/PyThorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piethorn-0.1.0.tar.gz -
Subject digest:
cfa0f1e24dd7597753cc9bf4efed2d26446743dd61b2fef79f9694d96717cf51 - Sigstore transparency entry: 1314164874
- Sigstore integration time:
-
Permalink:
Officer-Erik-1K-88/PyThorn@3a1ce4d1dc92dd25802e09eddc52a5912de4df93 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Officer-Erik-1K-88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a1ce4d1dc92dd25802e09eddc52a5912de4df93 -
Trigger Event:
push
-
Statement type:
File details
Details for the file piethorn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: piethorn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 83.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ab6e3712f1571e4c3f627add3dbd5c0e1f42a0bdc1d2f0068bb7779f2e33845
|
|
| MD5 |
0ecd9d949f8350f44efbcd1073cb3eb8
|
|
| BLAKE2b-256 |
c9c7bf15c16950adecd99b392075d28d61917ac7a7bfb2e56e174dbf70b3c20a
|
Provenance
The following attestation bundles were made for piethorn-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Officer-Erik-1K-88/PyThorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piethorn-0.1.0-py3-none-any.whl -
Subject digest:
4ab6e3712f1571e4c3f627add3dbd5c0e1f42a0bdc1d2f0068bb7779f2e33845 - Sigstore transparency entry: 1314165008
- Sigstore integration time:
-
Permalink:
Officer-Erik-1K-88/PyThorn@3a1ce4d1dc92dd25802e09eddc52a5912de4df93 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Officer-Erik-1K-88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a1ce4d1dc92dd25802e09eddc52a5912de4df93 -
Trigger Event:
push
-
Statement type: