From f0b6d85d5ca25c06cddb59b54f99e3c08e2e4bf9 Mon Sep 17 00:00:00 2001 From: danellecline Date: Fri, 1 Mar 2024 17:15:02 -0800 Subject: [PATCH] added missing src/main_json_generator_args.py --- src/main_json_generator_args.py | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/main_json_generator_args.py diff --git a/src/main_json_generator_args.py b/src/main_json_generator_args.py new file mode 100644 index 0000000..b5dbb4a --- /dev/null +++ b/src/main_json_generator_args.py @@ -0,0 +1,84 @@ +from argparse import ArgumentParser, RawTextHelpFormatter + + +def parse_arguments(): + description = ("PyPAM based processing. Generates JSONs with audio metadata for NRS flac files, " + "IcListen wav files, and Soundtrap wav files from either a local directory or gs/s3 bucket.") + example = """ +Examples: + src/main_json_gen.py \\ + --json-base-dir=tests/json/nrs \\ + --output-dir=output \\ + --uri=s3://pacific-sound-ch01 \\ + --start=20220902 \\ + --end=20220902 \\ + --search=MARS \\ + --recorder=NRS + """ + + parser = ArgumentParser( + description=description, epilog=example, formatter_class=RawTextHelpFormatter + ) + + class InstrumentType: + NRS = 'NRS' + ICLISTEN = 'ICLISTEN' + SOUNDTRAP = 'SOUNDTRAP' + + parser.add_argument( + "--recorder", + choices=[InstrumentType.NRS, InstrumentType.ICLISTEN, InstrumentType.SOUNDTRAP], + required=True, + help="Choose the audio instrument type",) + + parser.add_argument( + "--json-base-dir", + type=str, + metavar="dir", + required=True, + help="JSON base directory to store the metadata", + ) + + parser.add_argument( + "--output-dir", + type=str, + metavar="dir", + required=True, + help="Output directory to store logs", + ) + + parser.add_argument( + "--uri", + type=str, + metavar="uri", + required=True, + default=None, + help="Location of the audio files. S3 location supported for IcListen or Soundtrap, and GS supported for NRS.", + ) + + parser.add_argument( + "--start", + type=str, + required=True, + metavar="YYYYMMDD", + help="The starting date to be processed.", + ) + + parser.add_argument( + "--end", + type=str, + required=True, + metavar="YYYYMMDD", + help="The ending date to be processed.", + ) + + parser.add_argument( + "--prefix", + type=str, + required=True, + nargs='+', + help="Prefix for search to match the audio files. Assumption is the prefix is separated by an " + "underscore, e.g. 'MARS_'.", + ) + + return parser.parse_args()