def YAML(v): try: return yaml.safe_load(v) except yaml.YAMLError as e: error_message = str(e) path = ([ types.LineColumnPath(e.problem_mark.line + 1, e.problem_mark.column + 1) ] if hasattr(e, "problem_mark") else None) raise YAMLInvalid(message="Invalid YAML", error_message=error_message, path=path) return v
def YAML(v: bytes) -> typing.Any: try: return yaml.safe_load(v) except yaml.MarkedYAMLError as e: error_message = str(e) path = [ types.LineColumnPath(e.problem_mark.line + 1, e.problem_mark.column + 1) ] raise YAMLInvalid( message="Invalid YAML", error_message=error_message, path=path ) except yaml.YAMLError as e: error_message = str(e) raise YAMLInvalid(message="Invalid YAML", error_message=error_message)
def YAML(v: str) -> typing.Any: try: return yaml.safe_load(v) except yaml.MarkedYAMLError as e: error_message = str(e) path = [] if e.problem_mark is not None: path.append( types.LineColumnPath(e.problem_mark.line + 1, e.problem_mark.column + 1)) raise YAMLInvalid(message="Invalid YAML", error_message=error_message, path=path) except yaml.YAMLError as e: error_message = str(e) raise YAMLInvalid(message="Invalid YAML", error_message=error_message)