Initial upload: ConfDoc v0.1.0 - Config validation and documentation generator
This commit is contained in:
18
src/confdoc/parsers/yaml_parser.py
Normal file
18
src/confdoc/parsers/yaml_parser.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import yaml
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
|
||||||
|
class YamlParser:
|
||||||
|
"""Parser for YAML configuration files."""
|
||||||
|
|
||||||
|
def parse(self, content: str) -> Dict[str, Any]:
|
||||||
|
"""Parse YAML content into a dictionary."""
|
||||||
|
return yaml.safe_load(content)
|
||||||
|
|
||||||
|
def dump(self, data: Dict[str, Any]) -> str:
|
||||||
|
"""Dump dictionary to YAML string."""
|
||||||
|
return yaml.dump(data, default_flow_style=False, sort_keys=False)
|
||||||
|
|
||||||
|
def get_format(self) -> str:
|
||||||
|
"""Return the format name."""
|
||||||
|
return "yaml"
|
||||||
Reference in New Issue
Block a user