fix: load remote blocklist for export and fix diff with toml input
This commit is contained in:
parent
0b37e7a10c
commit
1c2f65b433
@ -12,6 +12,10 @@ from fediverse_blocklist_deploy.helpers import blocklist_to_markdown, blocklist_
|
||||
|
||||
|
||||
def load_blocklist_file(filename: str) -> [Instance]:
|
||||
if filename.endswith("json"):
|
||||
with open(filename) as f:
|
||||
instances = blocklist_json_to_instances(json.load(f))
|
||||
else:
|
||||
with open(filename, "r") as f:
|
||||
data = toml.load(f)
|
||||
instances = []
|
||||
@ -121,11 +125,10 @@ def cli():
|
||||
token = os.getenv('MBD_TOKEN')
|
||||
|
||||
"""Get a remote blocklist only when necessary"""
|
||||
if args.action in ["diff", "deploy"]:
|
||||
if args.action in ["diff", "deploy", "export"]:
|
||||
"""if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
|
||||
if args.remote_blocklist:
|
||||
with open(args.remote_blocklist) as f:
|
||||
remote_blocklist = blocklist_json_to_instances(json.load(f))
|
||||
remote_blocklist = load_blocklist_file(args.remote_blocklist)
|
||||
else:
|
||||
remote_blocklist = load_blocklist_from_instance(server=args.server, token=token)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user