|
19 | 19 | import re |
20 | 20 |
|
21 | 21 |
|
22 | | -parser = argparse.ArgumentParser(prog='dsc-datatool', description='Export DSC data into various formats and databases.') |
23 | | -parser.add_argument('-c', '--conf', nargs=1) |
24 | | -# Specify the YAML configuration file to use (default to ~/.dsc-datatool.conf), |
25 | | -# any command line option will override the options in the configuration file. |
26 | | -# See B<dsc-datatool.conf(5)> for more information. |
27 | | -parser.add_argument('-s', '--server', nargs=1, required=True) |
28 | | -# Specify the server for where the data comes from. |
29 | | -parser.add_argument('-n', '--node', nargs=1, required=True) |
30 | | -# Specify the node for where the data comes from. |
31 | | -parser.add_argument('-x', '--xml', action='append') |
32 | | -# Read DSC data from the given file or directory, can be specified multiple |
33 | | -# times. |
34 | | -# If a directory is given then all files ending with B<.xml> will be read. |
35 | | -parser.add_argument('-d', '--dat', action='append') |
36 | | -# Read DSC data from the given directory, can be specified multiple |
37 | | -# times. |
38 | | -# Note that the DAT format is depended on the filename to know what type |
39 | | -# of data it is. |
40 | | -parser.add_argument('--dataset', action='append') |
41 | | -# Specify that only the list of datasets will be processed, the list is comma |
42 | | -# separated and the option can be given multiple times. |
43 | | -parser.add_argument('-o', '--output', action='append') |
44 | | -# =item B<[ -o | --output ] <sep><type>[<sep>option=value...]> |
45 | | -# |
46 | | -# Output data to B<type> and use B<separator> as an options separator, example: |
47 | | -# |
48 | | -# --output ;Carbon;host=localhost;port=2003 |
49 | | -# |
50 | | -# Can be specified multiple times to output to more then one. |
51 | | -# |
52 | | -# To see a full list of options, check the man-page of the output module: |
53 | | - # |
54 | | - # man App:DSC::DataTool::Output::NAME |
55 | | -parser.add_argument('-t', '--transform', action='append') |
56 | | -# =item B<[ -t | --transform ] <sep><type><sep><datasets>[<sep>option=value...]> |
57 | | -# |
58 | | -# Use the transformer B<type> to change the list of datasets in B<datasets>, |
59 | | -# example: |
60 | | -# |
61 | | -# --transform ;ReRanger;rcode_vs_replylen;type=sum;range=/128 |
62 | | -# |
63 | | -# B<datasets> is a comma separated list of datasets to run the tranformer on, |
64 | | -# because of this do not use comma (,) as a separator. B<*> in B<datasets> will |
65 | | -# make the tranformer run on all datasets. |
66 | | -# |
67 | | -# Can be specific multiple times to chain transformation, the chain will be |
68 | | -# executed in the order on command line with one exception. All transformations |
69 | | -# specified for dataset B<*> will be executed before named dataset |
70 | | -# transformations. |
71 | | -# |
72 | | -# To see a full list of options, check the man-page of the transformer module: |
73 | | -# |
74 | | -# man App:DSC::DataTool::Transformer::NAME |
75 | | -# |
76 | | -# For a list of datasets see the DSC configuration that created the data files |
77 | | -# and the documentation for the Presenter. |
78 | | -parser.add_argument('-g', '--generator', action='append') |
79 | | -# =item B<[ -g | --generator ] <list of generators>> |
80 | | -# |
81 | | -# Use the specified generators to generate additional datasets, the list is comma |
82 | | -# separated and the option can be given multiple times. |
83 | | -# |
84 | | -parser.add_argument('--list', action='store_true') |
85 | | -# List the available B<inputs>, B<generators>, B<transformers> and B<outputs>. |
86 | | -parser.add_argument('--skipped-key', nargs=1, default='-:SKIPPED:-') |
87 | | -# Set the special DSC skipped key, default to "-:SKIPPED:-". |
88 | | -parser.add_argument('--skipped-sum-key', nargs=1, default='-:SKIPPED_SUM:-') |
89 | | -# Set the special DSC skipped sum key, default to "-:SKIPPED_SUM:-". |
90 | | -parser.add_argument('-v', '--verbose', action='count', default=0) |
91 | | -# Increase the verbose level, can be given multiple times. |
92 | | -parser.add_argument('-V', '--version', action='version', version='%(prog)s v'+__version__) |
93 | | -# Display version and exit. |
| 22 | +parser = argparse.ArgumentParser(prog='dsc-datatool', |
| 23 | + description='Export DSC data into various formats and databases.', |
| 24 | + epilog='See man-page dsc-datatool(1) and dsc-datatool [generator|transformer|output] <name>(5) for more information') |
| 25 | +parser.add_argument('-c', '--conf', nargs=1, |
| 26 | + help='Not implemented') |
| 27 | +# help='Specify the YAML configuration file to use (default to ~/.dsc-datatool.conf), any command line option will override the options in the configuration file. See dsc-datatool.conf(5)for more information.') |
| 28 | +parser.add_argument('-s', '--server', nargs=1, |
| 29 | + help='Specify the server for where the data comes from. (required)') |
| 30 | +parser.add_argument('-n', '--node', nargs=1, |
| 31 | + help='Specify the node for where the data comes from. (required)') |
| 32 | +parser.add_argument('-x', '--xml', action='append', |
| 33 | + help='Read DSC data from the given file or directory, can be specified multiple times. If a directory is given then all files ending with .xml will be read.') |
| 34 | +parser.add_argument('-d', '--dat', action='append', |
| 35 | + help='Read DSC data from the given directory, can be specified multiple times. Note that the DAT format is depended on the filename to know what type of data it is.') |
| 36 | +parser.add_argument('--dataset', action='append', |
| 37 | + help='Specify that only the list of datasets will be processed, the list is comma separated and the option can be given multiple times.') |
| 38 | +parser.add_argument('-o', '--output', action='append', |
| 39 | + help='"<sep><output>[<sep>option=value...]>" Output data to <output> and use <separator> as an options separator.') |
| 40 | +parser.add_argument('-t', '--transform', action='append', |
| 41 | + help='"<sep><name><sep><datasets>[<sep>option=value...]>" Use the transformer <name> to change the list of datasets in <datasets>.') |
| 42 | +parser.add_argument('-g', '--generator', action='append', |
| 43 | + help='"<name>[,<name>,...]" or "<sep><name>[<sep>option=value...]>" Use the specified generators to generate additional datasets.') |
| 44 | +parser.add_argument('--list', action='store_true', |
| 45 | + help='List the available generators, transformers and outputs then exit.') |
| 46 | +parser.add_argument('--skipped-key', nargs=1, default='-:SKIPPED:-', |
| 47 | + help='Set the special DSC skipped key. (default to "-:SKIPPED:-")') |
| 48 | +parser.add_argument('--skipped-sum-key', nargs=1, default='-:SKIPPED_SUM:-', |
| 49 | + help='Set the special DSC skipped sum key. (default to "-:SKIPPED_SUM:-")') |
| 50 | +parser.add_argument('-v', '--verbose', action='count', default=0, |
| 51 | + help='Increase the verbose level, can be given multiple times.') |
| 52 | +parser.add_argument('-V', '--version', action='version', version='%(prog)s v'+__version__, |
| 53 | + help='Display version and exit.') |
94 | 54 |
|
95 | 55 | args = parser.parse_args() |
96 | 56 |
|
@@ -258,6 +218,21 @@ def main(): |
258 | 218 | log_level = 0 |
259 | 219 | logging.basicConfig(format='%(asctime)s %(levelname)s %(module)s: %(message)s', level=log_level, stream=sys.stderr) |
260 | 220 |
|
| 221 | + if args.list: |
| 222 | + print('Generators:') |
| 223 | + for name in _generators: |
| 224 | + print('',name) |
| 225 | + print('Transformers:') |
| 226 | + for name in _transformers: |
| 227 | + print('',name) |
| 228 | + print('Outputs:') |
| 229 | + for name in _outputs: |
| 230 | + print('',name) |
| 231 | + return 0 |
| 232 | + |
| 233 | + if not args.server or not args.node: |
| 234 | + raise Exception('--server and --node must be given') |
| 235 | + |
261 | 236 | if isinstance(args.server, list): |
262 | 237 | args.server = ' '.join(args.server) |
263 | 238 | elif not isinstance(args.server, str): |
|
0 commit comments