fix: Remove id from export

As this wil not be the same id on other instances exporting it does not make sense
This commit is contained in:
moanos [he/him] 2023-01-25 23:36:25 +01:00
parent 58998e1c17
commit 8a8a725002

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__":