Exemple #1
0
def yaml_load(file, as_namespace=False):
    if as_namespace:
        yaml = YAML(typ='safe', pure=True)
        yaml.Constructor = YAMLNamespaceConstructor
    else:
        yaml = YAML(typ='safe')
    return yaml.load(file)
Exemple #2
0
def yaml_no_ts() -> YAML:
    """
    Get a YAML loader that won't parse timestamps into datetime objects.

    Such datetime objects can't be easily dumped into JSON.
    """
    yaml = YAML(typ="rt")
    yaml.preserve_quotes = True  # type: ignore
    yaml.Constructor = _RoundTripNoTimeStampConstructor
    return yaml