Text Helper API¶
text
¶
Extract and format source fragments without discarding project comments.
TemplateError
¶
Bases: ValueError
Raised when a source template does not match the expected structure.
extract_service
¶
Extract one Compose service with its leading project comments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Complete Compose source containing a top-level services section. |
required |
service_name
|
str
|
Exact service key to extract. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The selected service block with one trailing newline. |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If the services section or requested service is absent. |
Note
This intentionally avoids YAML parsing so operator-facing comments and unresolved Compose variables survive generation verbatim.
Source code in docker/src/maraudarr/text.py
extract_foundation
¶
Extract shared anchors and the opening services key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Complete project-owned base Compose template. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Foundation text ending immediately after |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If either required structural marker is absent. |
Source code in docker/src/maraudarr/text.py
extract_footer
¶
Extract the final networks section from the base Compose template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Complete project-owned base Compose template. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Footer text beginning at the networks purpose comment. |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If the networks marker is absent. |
Source code in docker/src/maraudarr/text.py
extract_env_preamble
¶
Extract the copyright and description preamble from an environment file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Complete project-owned environment source. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Preamble text ending before the first setting group. |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If the first setting marker is absent. |
Source code in docker/src/maraudarr/text.py
extract_env_sections
¶
Split framed environment sections while retaining comments verbatim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Complete project-owned environment source. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Ordered mapping of section titles to newline-terminated source blocks. |
dict[str, str]
|
Copyright and file-description frames are excluded. |
Source code in docker/src/maraudarr/text.py
strip_yaml_key
¶
Remove one service-level YAML key and its nested content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
str
|
Extracted Compose service block. |
required |
key
|
str
|
Exact four-space key name to remove. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The normalized block, unchanged when the key is absent. |
Source code in docker/src/maraudarr/text.py
remove_comment_group
¶
Remove one Homepage environment group identified by its heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
str
|
Homepage Compose service block. |
required |
heading
|
str
|
Exact project-owned comment text introducing the group. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The normalized block, unchanged when the heading is absent. |
Source code in docker/src/maraudarr/text.py
aligned_yaml_lines
¶
Format a logical YAML group with aligned inline comments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entries
|
list[tuple[str, str]]
|
Ordered |
required |
indent
|
int
|
Number of leading spaces applied to every output line. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Newline-separated YAML lines, or an empty string for no entries. |