Split loading, saving, and applying camera config file
This commit is contained in:
parent
b73a8f7ec5
commit
c887f990b5
3 changed files with 62 additions and 55 deletions
|
|
@ -17,18 +17,23 @@ TYPES = {
|
|||
}
|
||||
|
||||
|
||||
def convert_config(config):
|
||||
def convert_config(config: dict) -> dict:
|
||||
"""Convert datatype of config based on type dictionary."""
|
||||
global TYPES
|
||||
|
||||
for key in config:
|
||||
if key in TYPES:
|
||||
config[key] = TYPES[key](config[key])
|
||||
config[key] = TYPES[key](config[key])
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def load_config(yaml_path):
|
||||
def load_config(yaml_path: str) -> dict:
|
||||
"""Load YAML file, pass through dictionary conversion, and return."""
|
||||
with open(yaml_path) as config_file:
|
||||
return convert_config(yaml.load(config_file))
|
||||
return yaml.load(config_file)
|
||||
|
||||
|
||||
def save_config(config: dict, yaml_path: str):
|
||||
with open('yaml_path', 'w') as outfile:
|
||||
yaml.dump(config, outfile)
|
||||
Loading…
Add table
Add a link
Reference in a new issue