41 parser = argparse.ArgumentParser(
42 description=description,
43 fromfile_prefix_chars=
"@",
44 formatter_class=argparse.RawDescriptionHelpFormatter,
45 epilog=
"Data IDs are expected to be of the form:\n" 46 " --id k1=v11[^v12[...]] [k2=v21[^v22[...]]\n" 49 " 1. --id visit=12345 raft=1,1\n" 50 " 2. --id skyTile=12345\n" 51 " 3. --id visit=12 raft=1,2^2,2 sensor=1,1^1,3\n" 53 "The first example identifies all sensors in raft 1,1 of visit " 54 "12345. The second identifies all sources/objects in sky-tile " 55 "12345. The cross product is computed for keys with multiple " 56 "values, so the third example is equivalent to:\n" 57 " --id visit=12 raft=1,2 sensor=1,1\n" 58 " --id visit=12 raft=1,2 sensor=1,3\n" 59 " --id visit=12 raft=2,2 sensor=1,1\n" 60 " --id visit=12 raft=2,2 sensor=1,3\n" 62 "Redundant specification of a data ID will *not* result in " 63 "loads of duplicate data - data IDs are de-duped before ingest " 64 "starts. Note also that the keys allowed in data IDs are " 65 "specific to the type of data the ingestion script deals with. " 66 "For example, one cannot load sensor metadata by sky tile ID, nor " 67 "sources by sensor (CCD) ID.\n" 69 "Any omitted keys are assumed to take all legal values. So, " 70 "`--id raft=1,2` identifies all sensors of raft 1,2 for all " 73 "Finally, calling an ingestion script multiple times is safe. " 74 "Attempting to load the same data item twice will result " 75 "in an error or (if --strict is specified) or cause previously " 76 "loaded data item to be skipped. Database activity is strictly " 78 parser.convert_arg_line_to_args = _line_to_args
81 "-d",
"--database", dest=
"database",
82 help=
"MySQL database to load CSV files into.")
84 "-s",
"--strict", dest=
"strict", action=
"store_true",
85 help=
"Error out if previously ingested, incomplete, or otherwise " 86 "suspicious data items are encountered (by default, these are " 87 "skipped). Note that if --database is not supplied, detecting " 88 "previously ingested data is not possible.")
90 "-i",
"--id", dest=
"id", nargs=
"+", default=
None, action=
"append",
91 help=
"Data ID specifying what to ingest. May appear multiple times.")
94 "-R",
"--registry", dest=
"registry", help=
"Input registry path; " 95 "used for all input roots. If omitted, a file named registry.sqlite3 " 96 "must exist in each input root.")
98 "outroot", help=
"Output directory for CSV files")
100 "inroot", nargs=
"+" if inRootsRequired
else "*",
101 help=
"One or more input root directories")
def makeArgumentParser(description, inRootsRequired=True, addRegistryOption=True)