utils
¶
Utils for code generation.
Functions:
Name | Description |
---|---|
get_relative_import |
Get a complete import statement or empty string if importing from same file. |
get_relative_path |
Get the relative path of the template. |
get_relative_import
¶
get_relative_import(
import_path: str, template_path: str, imports: str
) -> str
Get a complete import statement or empty string if importing from same file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
import_path
|
str
|
The import path (dot notation, e.g., streams.audio) |
required |
template_path
|
str
|
The template path (e.g., streams/audio.py.jinja) |
required |
imports
|
str
|
The comma-separated list of imports |
required |
Returns:
Type | Description |
---|---|
str
|
The complete import statement or empty string if importing from same file |
get_relative_path
¶
get_relative_path(
import_path: str, template_path: str | Path
) -> str | None
Get the relative path of the template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
import_path
|
str
|
The import path (dot notation, e.g., streams.audio) |
required |
template_path
|
str | Path
|
The template path (e.g., streams/audio.py.jinja) |
required |
Returns:
Type | Description |
---|---|
str | None
|
The relative path of the template, or None if importing from same file |