Compare commits
10 Commits
docker_bui
...
8a8a725002
Author | SHA1 | Date | |
---|---|---|---|
8a8a725002 | |||
58998e1c17 | |||
a484a41b45 | |||
![]() |
8d5676d0b2 | ||
6d2a4d82b4 | |||
![]() |
d9d3f02fda | ||
0fca58810a | |||
181ac45bbf | |||
6a2a13bd74 | |||
0dd6930c0f |
@@ -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__":
|
||||
|
@@ -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"]
|
||||
|
Reference in New Issue
Block a user