Skip to main content

🚀 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:

  • 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:])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

parsenaut-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file parsenaut-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: parsenaut-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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

Hashes for parsenaut-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 207bd0e7fc9ec5952d3c27dc0faa08ae39532d7ffeecc38d00309ea40f99687b
MD5 84afd60a5010df3de9d8f51c554f3286
BLAKE2b-256 752b7f1f89048ef476ca67ad0ddbc784f899a2d0765c327144e4d33381e2239c

See more details on using hashes here.

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