INNER CODE UNIT · Python

_get_oscal_file_type

usnistgov/OSCAL · src/utils/oscal-content-validator.py:12

def _get_oscal_file_type(filename):
    if filename.endswith("json"):
        return "json"
    elif filename.endswith("xml") or filename.endswith("xsd"):
        return "xml"
    elif filename.endswith("yaml") or filename.endswith("yml"):
        return "yaml"
    else:
        raise("Not a valid OSCAL file.")


def read_file(filename, ftype):
    with io.open(filename, 'r', encoding="utf-8") as f:
        if ftype == "json":
            filedata = json.load(f)
        if ftype == "yaml":
            yaml = YAML()
            filedata = yaml.load(f)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…