mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
refactor: mark module_utils modules as private (#782)
##### SUMMARY All `module_utils` are now marked as **private**. None of the modules were intended for public use. Similar to https://togithub.com/ansible-collections/community.general/issues/11312
This commit is contained in:
parent
0f23e6c58c
commit
cfa0d181f7
152 changed files with 283 additions and 239 deletions
40
plugins/module_utils/_vendor/hcloud/exp/zone.py
Normal file
40
plugins/module_utils/_vendor/hcloud/exp/zone.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"""
|
||||
The `exp.zone` module is a namespace that holds experimental features for the `hcloud-python`
|
||||
library, breaking changes may occur within minor releases.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
__all__ = [
|
||||
"is_txt_record_quoted",
|
||||
"format_txt_record",
|
||||
]
|
||||
|
||||
|
||||
def is_txt_record_quoted(value: str) -> bool:
|
||||
"""
|
||||
Check whether a TXT record is already quoted.
|
||||
|
||||
- hello world => false
|
||||
- "hello world" => true
|
||||
"""
|
||||
return value.startswith('"') and value.endswith('"')
|
||||
|
||||
|
||||
def format_txt_record(value: str) -> str:
|
||||
"""
|
||||
Format a TXT record by splitting it in quoted strings of 255 characters.
|
||||
Existing quotes will be escaped.
|
||||
|
||||
- hello world => "hello world"
|
||||
- hello "world" => "hello \"world\""
|
||||
"""
|
||||
value = value.replace('"', '\\"')
|
||||
|
||||
parts = []
|
||||
for start in range(0, len(value), 255):
|
||||
end = min(start + 255, len(value))
|
||||
parts.append('"' + value[start:end] + '"')
|
||||
value = " ".join(parts)
|
||||
|
||||
return value
|
||||
Loading…
Add table
Add a link
Reference in a new issue