- Added type hinting (for now, 3.5-compatible) - Split `db` namespace into `db` module and `model` namespace - Changed elastic search to be created lazily for each operation - Changed to class based approach in entity serialization to allow stronger typing - Removed `required` argument from `context.get_*` family of functions; now it's implied if `default` argument is omitted - Changed `unalias_dict` implementation to use less magic inputs
27 lines
753 B
Python
27 lines
753 B
Python
from typing import Dict
|
|
import os
|
|
import yaml
|
|
|
|
|
|
def merge(left: Dict, right: Dict) -> Dict:
|
|
for key in right:
|
|
if key in left:
|
|
if isinstance(left[key], dict) and isinstance(right[key], dict):
|
|
merge(left[key], right[key])
|
|
elif left[key] != right[key]:
|
|
left[key] = right[key]
|
|
else:
|
|
left[key] = right[key]
|
|
return left
|
|
|
|
|
|
def read_config() -> Dict:
|
|
with open('../config.yaml.dist') as handle:
|
|
ret = yaml.load(handle.read())
|
|
if os.path.exists('../config.yaml'):
|
|
with open('../config.yaml') as handle:
|
|
ret = merge(ret, yaml.load(handle.read()))
|
|
return ret
|
|
|
|
|
|
config = read_config() # pylint: disable=invalid-name
|