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, ...)
Undocumented
| 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. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _class |
Undocumented |
| Instance Variable | _classname |
Undocumented |
| Instance Variable | _directory |
Undocumented |
| Instance Variable | _filename |
Undocumented |
| Instance Variable | _postfix |
Undocumented |
| Instance Variable | _prefix |
Undocumented |
| Instance Variable | _replacements |
Undocumented |
| Instance Variable | _template |
Undocumented |
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:Path | Directory where the generated Python file is created. |
relativePath | 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. |