generator.utils
Utils.
1"""Utils.""" 2 3import urllib.request 4from pathlib import Path 5 6LOOKER_HUB_URL = "https://raw.githubusercontent.com/mozilla/looker-hub/main" 7 8 9def get_file_from_looker_hub(path: Path): 10 """Download a specific lookml artifact from looker-hub.""" 11 file = path.name 12 artifact_type = path.parent.name 13 namespace = path.parent.parent.name 14 print(f"{LOOKER_HUB_URL}/{namespace}/{artifact_type}/{file}") 15 with urllib.request.urlopen( 16 f"{LOOKER_HUB_URL}/{namespace}/{artifact_type}/{file}" 17 ) as response: 18 lookml = response.read().decode(response.headers.get_content_charset()) 19 path.parent.mkdir(parents=True, exist_ok=True) 20 path.write_text(lookml)
LOOKER_HUB_URL =
'https://raw.githubusercontent.com/mozilla/looker-hub/main'
def
get_file_from_looker_hub(path: pathlib.Path):
10def get_file_from_looker_hub(path: Path): 11 """Download a specific lookml artifact from looker-hub.""" 12 file = path.name 13 artifact_type = path.parent.name 14 namespace = path.parent.parent.name 15 print(f"{LOOKER_HUB_URL}/{namespace}/{artifact_type}/{file}") 16 with urllib.request.urlopen( 17 f"{LOOKER_HUB_URL}/{namespace}/{artifact_type}/{file}" 18 ) as response: 19 lookml = response.read().decode(response.headers.get_content_charset()) 20 path.parent.mkdir(parents=True, exist_ok=True) 21 path.write_text(lookml)
Download a specific lookml artifact from looker-hub.