""" :Author: Daniel Mohr :Email: daniel.mohr@dlr.de :Date: 2021-03-22, 2021-07-01, 2021-12-06 (last change). :License: GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007. """
""" :Author: Daniel Mohr :Email: daniel.mohr@dlr.de :Date: 2021-01-19 (last change). """ msg = '"%s" is not a directory' % data raise argparse.ArgumentTypeError(msg)
""" :Author: Daniel Mohr :Email: daniel.mohr@dlr.de :Date: 2021-12-06 (last change). """ # pylint: disable=too-many-locals,too-many-statements description='pydabu is a script to check a data bubble.', epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) # parent parser to describe common argument '-output_format', nargs=1, type=str, choices=['human_readable', 'json', 'json1'], required=False, default=['json1'], dest='output_format', help='Set the output format to use. ' + 'human_readable gives a nice json output with skipped data. ' + 'json is the normal json output. json1 is the full data with ' + 'nice output like human_readable. ' + 'default: json1', metavar='f') '-directory', nargs="+", type=check_arg_directory, required=False, default=['.'], # this is not checked against the required type dest='directory', help='Set the directory to use. ' + 'You can also give a list of directories separated by space. ' + 'default: .', metavar='d') '-directory', nargs="+", type=check_arg_directory, required=True, dest='directory', help='Set the directory to use. ' + 'You can also give a list of directories separated by space.', metavar='d') '-file', nargs="+", type=check_arg_file, required=True, dest='file', help='Set the file(s) to use. ', metavar='f') '-indent', nargs=1, type=int, required=False, default=[4], dest='indent', help='In the output the elements will be indented ' + 'by this number of spaces.', metavar='i') '-skip_creating_checksums', action='store_true', required=False, dest='skip_creating_checksums', help='Skip creating checksums, which could take a while.') '-checksum_from_file', nargs=1, type=check_arg_file, required=False, dest='checksum_from_file', help='Try to get checksums from the given file.', metavar='f') '-dabu_instance_file', nargs=1, type=check_arg_file, required=False, default=['.dabu.json'], # this is not checked dest='dabu_instance_file', help='Gives the name of the file describing the content ' + 'of a data bubble. The name is relative to the given directory.', metavar='f') '-dabu_schema_file', nargs=1, type=check_arg_file, required=False, default=['.dabu.schema'], # this is not checked dest='dabu_schema_file', help='Gives the name of the file describing the necessary content ' + 'of a data bubble. The name is relative to the given directory.', metavar='f') # subparsers dest='subparser_name', help='There are different sub-commands with there own flags.') # subparser analyse_data_structure 'analyse_data_structure', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu analyse_data_structure -h', description='', epilog='', parents=[common_parser1, common_parser2]) # subparser check_nasa_ames_format 'check_nasa_ames_format', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu check_nasa_ames_format -h', description=description, epilog=epilog, parents=[common_parser1, common_parser3]) # subparser check_netcdf_file 'check_netcdf_file', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu check_netcdf_file -h', description=description, epilog=epilog, parents=[common_parser1, common_parser3]) # subparser check_file_format 'check_file_format', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu check_file_format -h', description=description, epilog=epilog, parents=[common_parser1, common_parser2, common_parser5]) # subparser common_json_format 'common_json_format', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu common_json_format -h', description=description, epilog=epilog, parents=[common_parser3, common_parser4]) # subparser create_data_bubble 'The data is generated with the command "check_file_format" ' 'create_data_bubble', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu create_data_bubble -h', description=description, epilog=epilog, parents=[common_parser2_required, common_parser4, common_parser5]) '-dabu_instance_file', nargs=1, type=check_arg_file_not_exists, required=False, default=['.dabu.json'], # this is not checked dest='dabu_instance_file', help='Gives the name of the file describing the content ' + 'of a data bubble. If this file already exists an error is raised. ' + 'The name is relative to the given directory.', metavar='f') '-dabu_schema_file', nargs=1, type=check_arg_file_not_exists, required=False, default=['.dabu.schema'], # this is not checked dest='dabu_schema_file', help='Gives the name of the file describing the necessary content ' + 'of a data bubble. If this file already exists an error is raised. ' + 'The name is relative to the given directory.', metavar='f') # subparser check_data_bubble 'check_data_bubble', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu check_data_bubble -h', description=description, epilog=epilog, parents=[common_parser2_required, common_parser6]) # subparser listschemas 'listschemas', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu listschemas -h', description=description, epilog=epilog) # the following artificial parameter is necessary to build the # documentation with sphinx-argparse or rather sphinxarg.ext '-output_format', nargs=1, type=str, choices=['simple', 'json'], required=False, default=['simple'], dest='output_format', help='Set the output format to use. ' + 'simple lists the json schmeas in lines. ' + 'json leads to a json output. ' + 'default: simple', metavar='f') # subparser data_bubble2jsonld 'data_bubble2jsonld', formatter_class=argparse.RawDescriptionHelpFormatter, help='For more help: pydabu data_bubble2jsonld -h', description=description, epilog=epilog, parents=[common_parser2_required, common_parser4, common_parser6]) '-dabu_jsonld_instance_file', nargs=1, type=check_arg_file_not_exists, required=False, default=['.dabu.json-ld'], # this is not checked dest='dabu_jsonld_instance_file', help='Gives the name of the file describing the content ' + 'of a data bubble as jsonld. ' + 'If this file already exists an error is raised. ' + 'The name is relative to the given directory. ' + 'default: .dabu.json-ld', metavar='f') '-dabu_jsonld_schema_file', nargs=1, type=check_arg_file_not_exists, required=False, default=['.dabu.json-ld.schema'], # this is not checked dest='dabu_jsonld_schema_file', help='Gives the name of the file describing the necessary content ' + 'of a data bubble with json-ld. ' + 'If this file already exists an error is raised. ' + 'The name is relative to the given directory. ' + 'default: .dabu.json-ld.schema', metavar='f') '-vocabulary', nargs=1, type=str, choices=['schema.org'], required=False, default=['schema.org'], dest='vocabulary', help='Sets the vocabulary to use. ' + 'At the moment only schema.org is implemented. ' + 'default: schema.org', metavar='v') '-cachefilename', nargs=1, type=str, required=False, default=[cachefilename], dest='cachefilename', help='We need data from schema.org. ' 'If you set cachefilename to an empty string, nothing is cached. ' 'If the file ends with common extension for compression, ' 'this comperession is used (e. g.: .gz, .lzma, .xz, .bz2). ' 'The file is created in the cachefilepath (see this option). ' 'default: "%s"' % cachefilename, metavar='f') tempfile.gettempdir(), 'json_schema_from_schema_org_' + getpass.getuser()) '-cachefilepath', nargs=1, type=str, required=False, default=[cachefilepath], dest='cachefilepath', help='This path is used for the cachefilename. ' 'If necessary, this directory will be created ' '(not the directory tree!). ' 'default: "%s"' % cachefilepath, metavar='p') '-author', nargs=1, type=str, required=False, dest='author', help='Sets the author of the data bubble. ' + 'If not given, it is not added to the dabu_jsonld_instance_file. ' + 'Anyway the dabu_jsonld_schema_file will require it. ' + 'You can just give a string or any json object.', metavar='p')
""" :Author: Daniel Mohr :Email: daniel.mohr@dlr.de :Date: 2021-01-25 (last change). """ # command line arguments: # parse arguments else: # no sub command given |