Parsenaut
🚀 Parse and launch classes as commands 🚀📦 Description
Scene-like applications may use inheritance for multiple user-defined classes in local scripts, lacking dynamic entry points and/or needing a path and class name to run. Whether your project looks something like:
from myproject import Scene
class Mandelbrot(Scene):
"""Mandelbrot example"""
...
class BurningShip(Scene):
"""Burning Ship example"""
...
One might want its usage to follow as:
# Lists all classes
$ myproject --help
📦 Scenes at (/home/user/scenes.py)
• mandelbrot Mandelbrot example
• burningship Burning Ship example
# Runs Mandelbrot().cli(*args)
$ myproject mandelbrot (args)
Parsenaut is a safe library for it that:
- Safe: Files are parsed with stdlib Abstract Syntax Trees and are never executed, saving import times and minimizing security issues in potentially untrusted scripts.
- Compatible: Works with Cyclopts or Typer command line libraries, at your taste.
- Flexible: Customizable class tags search, write your own implementation.
- Fast: Does not spawn a subprocess, uses stdlib
runpy
📦 Installation
Simply add the parsenaut package in your pyproject.toml:
[project]
dependencies = ["parsenaut"]
📦 Usage
# myproject/__main__.py
import sys
from pathlib import Path
from parsenaut._cyclopts import Launcher
if __name__ == "__main__":
launcher = Launcher(keyword="Scene")
for file in Path.cwd().glob("*.py"):
launcher.search(file)
launcher.cli(sys.argv[1:])
Release files for parsenaut 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| parsenaut-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / parsenaut-0.2.1-py3-none-any.whl
| Download URL | parsenaut-0.2.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d32d40e3f165cc10a017ed0bc6a92e924cfd69b7e39951af2bf7753afb1677be
|
|
BLAKE2b-256 checksum How to use checksums |
9b8f887049909e40e802de99c425104864c5dfaf0157af9d56812e39475e345d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|