🚀 Parse and launch classes as commands
Project description
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:
- No exec: Files are parsed with regex or abstract syntax trees and are never executed, saving import times and minimizing security issues in potentially untrusted scripts (non-greedy).
- Compatible: Works with Cyclopts or Typer command line libraries, at your taste.
- Flexible: Customizable class tags search, extensible classes.
- Fast: Does not spawn a subproces, 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__":
app = Launcher(keyword="Scene")
for file in Path.cwd().glob("*.py"):
app.search(file)
app.cli(sys.argv[1:])
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 Distributions
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 parsenaut-0.1.0-py3-none-any.whl.
File metadata
- Download URL: parsenaut-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffe1523477e7c9865df218f1315ee8f57d7ce47d8db127ed012ad01c0431772
|
|
| MD5 |
96bda236eefb97be938c658cdd52cc10
|
|
| BLAKE2b-256 |
24cecd4394b4176b62816c188e16f86116051ecaff533e593d047b91a047969d
|