Codebase list ctdconverter / 0478aa9
Made the converter to abort and fail at the first encountered error. Garbage in, garbage out. Luis de la Garza 6 years ago
5 changed file(s) with 16 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
5555
5656 - [Generation of Galaxy ToolConfig files](galaxy/README.md)
5757 - [Generation of CWL task files](cwl/README.md)
58
59 ## Fail Policy while processing several Files
60 `CTDConverter` can parse several CTDs and convert them. However, the process will be interrupted and an error code will be returned at the first encountered error (e.g., a CTD is not valid, there are missing support files, etc.).
5861
5962 ## Converting a single CTD
6063 In its simplest form, the converter takes an input CTD file and generates an output file. The following usage of `CTDConverter`:
104104 error("Could not load validation schema %s. Reason: %s" % (xsd_location, str(e)), 0)
105105 else:
106106 warning("Validation against a schema has not been enabled.", 0)
107
107108 for input_ctd in input_ctds:
108 try:
109 if schema is not None:
110 validate_against_schema(input_ctd, schema)
111 output_file = output_destination
112 # if multiple inputs are being converted, we need to generate a different output_file for each input
113 if is_converting_multiple_ctds:
114 output_file = os.path.join(output_file,
115 get_filename_without_suffix(input_ctd) + "." + output_file_extension)
116 info("Parsing %s" % input_ctd)
117 parsed_ctds.append(ParsedCTD(CTDModel(from_file=input_ctd), input_ctd, output_file))
118 except Exception, e:
119 error(str(e), 1)
120 continue
109 if schema is not None:
110 validate_against_schema(input_ctd, schema)
111
112 output_file = output_destination
113 # if multiple inputs are being converted, we need to generate a different output_file for each input
114 if is_converting_multiple_ctds:
115 output_file = os.path.join(output_file, get_filename_without_suffix(input_ctd) + "." + output_file_extension)
116 info("Parsing %s" % input_ctd)
117 parsed_ctds.append(ParsedCTD(CTDModel(from_file=input_ctd), input_ctd, output_file))
118
121119 return parsed_ctds
122120
123121
214214 converter.get_preferred_file_extension())
215215
216216 # let the converter do its own thing
217 return converter.convert_models(args, parsed_ctds)
217 converter.convert_models(args, parsed_ctds)
218 return 0
218219
219220 except KeyboardInterrupt:
220221 print("Interrupted...")
7676 stream.write("# Visit https://github.com/WorkflowConversion/CTDConverter for more information.\n\n")
7777 yaml.dump(cwl_tool, stream, default_flow_style=False)
7878 stream.close()
79
80 return 0
8179
8280
8381 # returns a dictionary
101101 # generate datatypes_conf.xml
102102 if args.data_types_destination is not None:
103103 generate_data_type_conf(supported_file_formats, args.data_types_destination)
104
105 return 0
106104
107105
108106 def parse_tools_list_file(tools_list_file):