mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-10 02:17:59 +00:00
cleanup load_config
This commit is contained in:
parent
4d4bebd0be
commit
c59cec0c31
|
@ -9,9 +9,13 @@ import yaml
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
with open('relay.yaml') as f:
|
with open('relay.yaml') as f:
|
||||||
yaml_file = yaml.load(f)
|
options = {}
|
||||||
whitelist = yaml_file['ap'].get('whitelist', [])
|
|
||||||
blocked = yaml_file['ap'].get('blocked_instances', [])
|
## Prevent a warning message for pyyaml 5.1+
|
||||||
|
if getattr(yaml, 'FullLoader', None):
|
||||||
|
options['Loader'] = yaml.FullLoader
|
||||||
|
|
||||||
|
yaml_file = yaml.load(f, **options)
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'db': yaml_file.get('db', 'relay.jsonld'),
|
'db': yaml_file.get('db', 'relay.jsonld'),
|
||||||
|
@ -19,9 +23,9 @@ def load_config():
|
||||||
'port': int(yaml_file.get('port', 8080)),
|
'port': int(yaml_file.get('port', 8080)),
|
||||||
'note': yaml_file.get('note', 'Make a note about your instance here.'),
|
'note': yaml_file.get('note', 'Make a note about your instance here.'),
|
||||||
'ap': {
|
'ap': {
|
||||||
'blocked_instances': [] if blocked is None else blocked,
|
'blocked_instances': yaml_file['ap'].get('blocked_instances', []),
|
||||||
'host': yaml_file['ap'].get('host', 'localhost'),
|
'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)
|
'whitelist_enabled': yaml_file['ap'].get('whitelist_enabled', False)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ idna==2.7
|
||||||
idna-ssl==1.1.0
|
idna-ssl==1.1.0
|
||||||
multidict==4.3.1
|
multidict==4.3.1
|
||||||
pycryptodome==3.9.4
|
pycryptodome==3.9.4
|
||||||
PyYAML==3.13
|
PyYAML>=5.1
|
||||||
simplejson==3.16.0
|
simplejson==3.16.0
|
||||||
yarl==1.2.6
|
yarl==1.2.6
|
||||||
cachetools
|
cachetools
|
||||||
|
|
Loading…
Reference in a new issue