From f09dd2891fe4dc9a796aaefc79510cd07d4d0746 Mon Sep 17 00:00:00 2001 From: pixelsoup42 Date: Fri, 13 Oct 2023 11:07:34 +0200 Subject: [PATCH] switch to graph_output, add metadata --- src/cardano_account_pandas_dumper/__main__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/cardano_account_pandas_dumper/__main__.py b/src/cardano_account_pandas_dumper/__main__.py index b1a4e99..6d1ee03 100644 --- a/src/cardano_account_pandas_dumper/__main__.py +++ b/src/cardano_account_pandas_dumper/__main__.py @@ -14,6 +14,7 @@ # Error codes due to project key rate limiting or capping PROJECT_KEY_ERROR_CODES = frozenset([402, 403, 418, 429]) +CREATOR_STRING="https://github.com/pixelsoup42/cardano_account_pandas_dumper" def _create_arg_parser(): result = argparse.ArgumentParser( @@ -67,9 +68,10 @@ def _create_arg_parser(): type=argparse.FileType("wb"), ) result.add_argument( - "--svg_output", - help="Path to SVG output file.", - type=argparse.FileType("wb"), + "--graph_output", + help="Path to graphics output file.", + type=str, + ) result.add_argument( "--detail_level", @@ -121,11 +123,11 @@ def main(): message="Following addresses do not look like valid staking addresses: " + " ".join(invalid_staking_addresses), ) - if not any([args.checkpoint_output, args.csv_output, args.xlsx_output, args.svg_output]): + if not any([args.checkpoint_output, args.csv_output, args.xlsx_output, args.graph_output]): parser.exit( status=1, message="No output specified, neeed at least one of --checkpoint_output," - + " --csv_output, --xlsx_output, --svg_output.\n", + + " --csv_output, --xlsx_output, --graph_output.\n", ) known_dict_from_file = jstyleson.load(args.known_file) if args.known_file else {} staking_addresses_set = frozenset(args.staking_address) @@ -227,12 +229,13 @@ def main(): ) except OSError as exception: warnings.warn(f"Failed to write .xlsx file: {exception}") - if args.svg_output: + if args.graph_output: reporter.plot_balance() try: - plt.savefig(args.svg_output,format='svg') + plt.savefig(args.graph_output, + metadata={"Creator":CREATOR_STRING,"Software":CREATOR_STRING}) except OSError as exception: - warnings.warn(f"Failed to write .svg file: {exception}") + warnings.warn(f"Failed to write graph file: {exception}") print("Done.")