How to use the lkml.load 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 load(filename):
    """Helper method to load a LookML file from tests/resources and parse it."""
    path = Path(__file__).parent / "resources" / filename
    with path.open() as file:
        return lkml.load(file)
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 / 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 ww-tech / lookml-tools / lkmltools / lookml.py View on Github external
raise IOError("Filename does not exist: %s" % infilepath)

        self.infilepath = infilepath
        if infilepath.endswith(".model.lkml"):
            self.filetype = 'model'
        elif infilepath.endswith(".view.lkml"):
            self.filetype = 'view'
        elif infilepath.endswith(".explore.lkml"):
            self.filetype = 'explore'
        else:
            raise Exception("Unsupported filename " + infilepath)
        self.base_filename = os.path.basename(infilepath)
        self.base_name = self.base_filename.replace(".model.lkml", "").replace(".explore.lkml", "").replace(".view.lkml", "")        

        with open(infilepath, 'r') as file:
            self.json_data = lkml.load(file)