Shared mixin for all Edit modules in factory.core/extend.edit/.
Eliminates copy-paste duplication across 10 Edit files by extracting
common YAML export utilities into a single cooperative mixin.
| Name | Description |
|---|---|
LiteralString |
str subclass that LiteralDumper renders as YAML block scalar (\|) |
LiteralDumper |
Custom yaml.SafeDumper with LiteralString support |
_literal_representer |
Representer function registered on LiteralDumper |
| Method | Description |
|---|---|
_remove_null_values(data, strip_empty=False) |
Recursively strip None (and optionally "") from dicts/lists |
_format_content(data) |
Wrap long/multiline strings as LiteralString for block scalar output |
_yaml_dump_to_file(data, file_path) |
Write data to YAML using LiteralDumper with standard options |
_yaml_load_from_file(file_path) |
Read and parse a YAML file via yaml.safe_load |
Place ObjEditBase before the primary parent in the class definition
so Python's MRO resolves the mixin's methods first:
from ObjEditBase import ObjEditBase, LiteralString, LiteralDumper
class ObjFooEdit(ObjEditBase, ObjFoo.ObjFoo):
...
Files that previously stripped empty strings (v != "") override
_remove_null_values with strip_empty=True as the default:
def _remove_null_values(self, data, strip_empty=True):
return super()._remove_null_values(data, strip_empty=strip_empty)