This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/qutebrowser/source_yaml.py

24 lines
538 B
Python

#!/bin/env python
# {{@@ header() @@}}
import yaml
from qutebrowser.config.configfiles import ConfigAPI # type: ignore
def dict_attrs(obj, path=''):
if isinstance(obj, dict):
for k, v in obj.items():
yield from dict_attrs(v, '{}.{}'.format(path, k) if path else k)
else:
yield path, obj
def source_yaml(config: ConfigAPI, filename: str):
with (config.configdir / filename).open() as f:
yaml_data = yaml.safe_load(f)
for k, v in dict_attrs(yaml_data):
config.set(k, v)