THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class documentation
class Stub: (source)
Constructor: Stub(template_name, class_name, prefix, postfix, ...)
Load and render source templates used by code-generation commands.
| Method | __compile |
Compile the generated filename and class name. |
| Method | __init__ |
Initialize a stub generator. |
| Method | __load |
Load the requested stub template. |
| Method | __parse |
Normalize a generated name and reject unsafe path components. |
| Method | __replace |
Replace placeholders in the loaded template. |
| Method | create |
Create the generated source file. |
| Method | render |
Render a packaged template without choosing a destination. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _class |
Name used to derive the generated filename and class name. |
| Instance Variable | _classname |
Python class name substituted into the generated source. |
| Instance Variable | _directory |
Path components locating the generated resource directory. |
| Instance Variable | _filename |
Filename used when rendering or storing the resource. |
| Instance Variable | _postfix |
Suffix appended to the derived filename and class name. |
| Instance Variable | _prefix |
Prefix prepended to the derived filename and class name. |
| Instance Variable | _replacements |
Placeholder values to apply to the loaded template. |
| Instance Variable | _template |
Name of the template file without its .stub suffix. |
Compile the generated filename and class name.
| Returns | |
None | The derived filename and class name are stored on the instance. |
| Raises | |
ValueError | If the generated filename does not match the accepted format. |
def __init__(self, template_name:
str, class_name: str, prefix: str | None = None, postfix: str | None = None, replacements: dict[ str, str] | None = None):
(source)
¶
Initialize a stub generator.
| Parameters | |
templatestr | Name of the template file without its .stub suffix. |
classstr | Name used to derive the generated filename and class name. |
prefix:str | None, optional | Prefix prepended to the derived filename and class name. |
postfix:str | None, optional | Suffix appended to the derived filename and class name. |
replacements:dict[str, str] | None, optional | Placeholder values to apply to the loaded template. |
| Returns | |
None | The instance is initialized in place. |
Load the requested stub template.
| Returns | |
str | The unmodified template content. |
| Raises | |
FileNotFoundError | If the requested stub file does not exist. |
ValueError | If the template name does not identify a packaged stub. |
Normalize a generated name and reject unsafe path components.
| Returns | |
tuple[str, ...] | Directory components followed by the file stem. |
| Raises | |
ValueError | If the name is empty, absolute, traverses a parent directory, or contains a component that cannot form a Python module name. |
def create(self, directory:
Path, relative_to: Path | None = None, extension: str = 'py') -> str:
(source)
¶
Create the generated source file.
| Parameters | |
directory:pathlib.Path | Directory where the generated Python file is created. |
relativepathlib.Path | None, optional | Path to which the generated file path should be made relative. Both paths are resolved before computing the relative path. If None, the file path is returned as an absolute path. |
extension:str, optional | File extension for the generated Python file. Defaults to "py". |
| Returns | |
str | Path to the generated file as a string. |
| Raises | |
FileNotFoundError | If the requested stub template does not exist. |
TypeError | If a replacement key or value is not a string. |
ValueError | If the generated filename, template name, or extension is invalid, or the resolved file is outside relative_to. |
Render a packaged template without choosing a destination.
| Returns | |
str | Template content with its class name and replacements applied. |