-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathconfig.py
More file actions
30 lines (26 loc) · 790 Bytes
/
Copy pathconfig.py
File metadata and controls
30 lines (26 loc) · 790 Bytes
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
"""Python to lua translator config class"""
import sys
import yaml
class Config:
"""Translator config."""
def __init__(self, filename=None):
self.data = {
"class": {
"return_at_the_end": False,
},
}
if filename is not None:
self.load(filename)
def load(self, filename):
"""Load config from the file"""
try:
with open(filename, "r") as stream:
data = yaml.load(stream)
self.data.update(data)
except FileNotFoundError:
pass # Use a default config if the file not found
except yaml.YAMLError as ex:
print(ex)
def __getitem__(self, key):
"""Get data values"""
return self.data[key]