20 parser = argparse.ArgumentParser(description = __doc__, )
21 parser.add_argument(
'--output', help=
'JSON output file', required =
True)
22 parser.add_argument(
'--transforms', help=
'Comma separated list of transforms to process', default=
'all')
23 cliargs = vars(parser.parse_args())
27 sys.path.insert(1, os.path.join(os.getcwd(),
'../scripts'))
32 if cliargs[
'transforms'] ==
'all':
35 myTrfs = [ os.path.basename(t)[:-3]
for t
in glob.glob(
'../scripts/*_tf.py') ]
37 myTrfs = cliargs[
'transforms'].
split(
',')
38 logging.info(
'Will process this list of transforms: {0}'.
format(
' '.
join(myTrfs)))
42 logging.info(
'Processing argument signatures for {0}'.
format(trf))
45 trfModule = __import__(
'{0}'.
format(trf), globals(), locals(), [
'getTransform'], 0)
47 logging.warning(
'Failed to import transform {0} - ignored'.
format(trf))
49 if 'getTransform' not in dir(trfModule):
50 logging.warning(
'Transform {0} has no getTransform() functionality - ignored for pickle'.
format(trf))
52 transform = trfModule.getTransform()
53 args = transform.parser.allArgs
55 logging.debug(
'Trf %s: %s', trf, args)
56 processedTrfs.append(trf)
58 myTrfSigDesc[trf] = transform.parser.getProdsysDesc
60 logging.info(
'Writing JSON signatures to {0}'.
format(cliargs[
'output']))
61 sigFile =
open(cliargs[
'output'],
'wb')
62 json.dump(myTrfSigDesc, sigFile, indent=4)
64 logging.error(
'Failed to dump pickled signatures to %s: %s', cliargs[
'output'], e)
67 logging.info(
'Successfully generated signature file "%s" for transforms %s', cliargs[
'output'], processedTrfs)