How to use the lkml.dump function in lkml

To help you get started, we’ve selected a few lkml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joshtemple / lkml / tests / test_functional.py View on Github external
def test_model_with_all_fields():
    path = Path(__file__).parent / "resources" / "model_with_all_fields.model.lkml"
    with path.open() as file:
        raw = file.read()

    parsed = lkml.load(raw)
    assert parsed is not None

    lookml = lkml.dump(parsed)
    assert lookml.replace("\n\n", "\n") == raw.replace("\n\n", "\n")
github joshtemple / lkml / scripts / test_github.py View on Github external
def test_file(path: Path):
    with path.open("r") as file:
        text = file.read()

    try:
        parsed = lkml.load(text)
    except Exception:
        shutil.copy(path, github_path / "load_errors" / path.name)
        logging.exception(f"Error parsing {path}")

    try:
        dumped = lkml.dump(parsed)
        lkml.load(dumped)
    except Exception:
        with open(github_path / "dump_errors" / path.name, "w+") as file:
            file.write(dumped)
        logging.exception(f"Error serializing {path}")
github joshtemple / lkml / tests / test_functional.py View on Github external
def test_view_with_all_fields():
    path = Path(__file__).parent / "resources" / "view_with_all_fields.view.lkml"
    with path.open() as file:
        raw = file.read()

    parsed = lkml.load(raw)
    assert parsed is not None

    lookml = lkml.dump(parsed)
    assert lookml.replace("\n\n", "\n") == raw.replace("\n\n", "\n")