This repository was archived by the owner on Feb 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.py
More file actions
62 lines (51 loc) · 1.58 KB
/
convert.py
File metadata and controls
62 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import json
import sys
from lookml_processor import LookMLProcessor, ConverterException
def load_config():
try:
config_stream = open('config.json')
except FileNotFoundError as e:
print('No config.json file found.', file=sys.stderr)
return None
except Exception as e:
print('There was an error reading the config json.', file=sys.stderr)
return None
config = json.load(config_stream)
config_stream.close()
return config
def load_input_json(config):
try:
input_stream = open(config['inputFile'])
except FileNotFoundError as e:
print('The inputFile in config.json was not found.', file=sys.stderr)
return None
except Exception as e:
print('There was an error reading the input json.', file=sys.stderr)
return None
input_json = json.load(input_stream)
input_stream.close()
return input_json
def build_props():
pass
def main():
# Import the config file
config = load_config()
if not config:
return
# Load the input json
input_json = load_input_json(config)
if not input_json:
return
# Create the processor
try:
processor = LookMLProcessor(input_json, config)
mode = config['operationMode']
# Process the data!
if mode == 'srx':
processor.process_srx()
elif mode == 'table':
processor.process_table()
print('LookML files written successfully.')
except ConverterException as e:
print('Error in processing: {}'.format(e), file=sys.stderr)
main()