Commit c59cec0c authored by Izalia Mae's avatar Izalia Mae
Browse files

cleanup load_config

parent 4d4bebd0
......@@ -9,9 +9,13 @@ import yaml
def load_config():
with open('relay.yaml') as f:
yaml_file = yaml.load(f)
whitelist = yaml_file['ap'].get('whitelist', [])
blocked = yaml_file['ap'].get('blocked_instances', [])
options = {}
## Prevent a warning message for pyyaml 5.1+
if getattr(yaml, 'FullLoader', None):
options['Loader'] = yaml.FullLoader
yaml_file = yaml.load(f, **options)
config = {
'db': yaml_file.get('db', 'relay.jsonld'),
......@@ -19,9 +23,9 @@ def load_config():
'port': int(yaml_file.get('port', 8080)),
'note': yaml_file.get('note', 'Make a note about your instance here.'),
'ap': {
'blocked_instances': [] if blocked is None else blocked,
'blocked_instances': yaml_file['ap'].get('blocked_instances', []),
'host': yaml_file['ap'].get('host', 'localhost'),
'whitelist': [] if whitelist is None else whitelist,
'whitelist': yaml_file['ap'].get('whitelist', []),
'whitelist_enabled': yaml_file['ap'].get('whitelist_enabled', False)
}
}
......
......@@ -6,7 +6,7 @@ idna==2.7
idna-ssl==1.1.0
multidict==4.3.1
pycryptodome==3.9.4
PyYAML==3.13
PyYAML>=5.1
simplejson==3.16.0
yarl==1.2.6
cachetools
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment