mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-09 18:08:00 +00:00
cleanup load_config
This commit is contained in:
parent
4d4bebd0be
commit
c59cec0c31
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue