From 8a8a725002087fdcdbcff121ed5a375b2065d90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Wed, 25 Jan 2023 23:36:25 +0100 Subject: [PATCH] fix: Remove id from export As this wil not be the same id on other instances exporting it does not make sense --- mastodon_blocklist_deploy/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mastodon_blocklist_deploy/cli.py b/mastodon_blocklist_deploy/cli.py index 89aa964..7bdb6e1 100644 --- a/mastodon_blocklist_deploy/cli.py +++ b/mastodon_blocklist_deploy/cli.py @@ -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__":