Merge branch 'develop'

This commit is contained in:
Georg Krause 2023-01-26 11:54:22 +01:00
commit d4c754c103
No known key found for this signature in database
GPG Key ID: 2970D504B2183D22
2 changed files with 9 additions and 3 deletions

View File

@ -38,6 +38,9 @@ def load_blocklist_from_instance(server: str, token: str) -> [Instance]:
else:
raise ConnectionError(f"Could not connect to the server ({response.status_code}: {response.reason})")
def remove_key_from_dict(dict, key):
del dict[key]
return dict
def cli():
parser = argparse.ArgumentParser(description='Deploy blocklist updates to a mastodon server')
@ -92,10 +95,10 @@ def cli():
Instance.apply_blocks_from_diff(diffs, args.server, token, args.no_delete)
elif args.action == "export":
if not args.output:
print(toml.dumps({"instances": [b.__dict__ for b in remote_blocklist]}))
print(toml.dumps({"instances": [remove_key_from_dict(b.__dict__, 'id') for b in remote_blocklist]}))
else:
with open(args.output, "w") as f:
toml.dump({"instances": [b.__dict__ for b in remote_blocklist]}, f)
toml.dump({"instances": [remove_key_from_dict(b.__dict__, 'id') for b in remote_blocklist]}, f)
if __name__ == "__main__":

View File

@ -38,7 +38,10 @@ class Instance:
self.reject_reports = instance_dict["reject_reports"]
def parse_local_block(self, instance_dict):
self.name = instance_dict["name"]
try:
self.name = instance_dict["name"]
except KeyError:
pass
self.domain = instance_dict["domain"]
self.severity = instance_dict["severity"]
self.public_comment = instance_dict["public_comment"]