fix: correct prefix handling in load_yaml function for improved YAML parsing

This commit is contained in:
mrT23 2025-08-14 18:49:06 +03:00
parent f645ebb938
commit 81525cd25a
No known key found for this signature in database
GPG key ID: D350490E39D5F5AD

View file

@ -739,7 +739,7 @@ def _fix_key_value(key: str, value: str):
def load_yaml(response_text: str, keys_fix_yaml: List[str] = [], first_key="", last_key="") -> dict: def load_yaml(response_text: str, keys_fix_yaml: List[str] = [], first_key="", last_key="") -> dict:
response_text_original = copy.deepcopy(response_text) response_text_original = copy.deepcopy(response_text)
response_text = response_text.strip('\n').removeprefix('```yaml').rstrip().removesuffix('```') response_text = response_text.strip('\n').removeprefix('yaml').removeprefix('```yaml').rstrip().removesuffix('```')
try: try:
data = yaml.safe_load(response_text) data = yaml.safe_load(response_text)
except Exception as e: except Exception as e: