diff --git a/MANIFEST.in b/MANIFEST.in index 2120b04b..fad88d64 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -10,7 +10,9 @@ include cwl_utils/cwlNodeEngineJSConsole.js include cwl_utils/cwlNodeEngineWithContext.js include testdata/*.cwl include testdata/*.yaml +include testdata/*.yml include testdata/*.input +include testdata/*.json include testdata/*.ttl include testdata/*.owl include testdata/*.js diff --git a/create_cwl_from_objects.py b/create_cwl_from_objects.py index 002678c4..a41fbd75 100755 --- a/create_cwl_from_objects.py +++ b/create_cwl_from_objects.py @@ -9,11 +9,11 @@ def main() -> None: """Generate a CWL object to match "cat-tool.cwl".""" - inputs = [cwl.CommandInputParameter(id="file1", type="File")] + inputs = [cwl.CommandInputParameter(id="file1", type_="File")] outputs = [ cwl.CommandOutputParameter( id="output", - type="File", + type_="File", outputBinding=cwl.CommandOutputBinding(glob="output"), ) ] diff --git a/cwl_utils/cwl_v1_0_expression_refactor.py b/cwl_utils/cwl_v1_0_expression_refactor.py index e5d86fd7..150aed46 100755 --- a/cwl_utils/cwl_v1_0_expression_refactor.py +++ b/cwl_utils/cwl_v1_0_expression_refactor.py @@ -35,7 +35,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool return process result = None for index, output in enumerate(process.outputs): - if output.type == "stdout": # TODO: add 'stdin' for CWL v1.1 + if output.type_ == "stdout": # TODO: add 'stdin' for CWL v1.1 if not result: result = copy.deepcopy(process) stdout_path = process.stdout @@ -46,7 +46,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool ).hexdigest() ) result.stdout = stdout_path - result.outputs[index].type = "File" + result.outputs[index].type_ = "File" output.outputBinding = cwl.CommandOutputBinding(stdout_path, None, None) if result: return result @@ -156,7 +156,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -171,7 +171,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -244,7 +244,7 @@ def traverse( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -262,7 +262,7 @@ def traverse( doc=outp.doc, format=outp.format, outputSource=f"main/{outp_id}", - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -346,9 +346,9 @@ def generate_etool_from_expr( new_type: Union[ List[Union[cwl.ArraySchema, cwl.InputRecordSchema]], Union[cwl.ArraySchema, cwl.InputRecordSchema], - ] = [clean_type_ids(t.type) for t in self_type if t.type] - elif self_type.type: - new_type = clean_type_ids(self_type.type) + ] = [clean_type_ids(t.type_) for t in self_type if t.type_] + elif self_type.type_: + new_type = clean_type_ids(self_type.type_) else: raise WorkflowException(f"Don't know how to make type from {self_type!r}.") inputs.append( @@ -363,7 +363,7 @@ def generate_etool_from_expr( else None, doc=self_type.doc if not isinstance(self_type, list) else None, format=self_type.format if not isinstance(self_type, list) else None, - type=new_type, + type_=new_type, extension_fields=self_type.extension_fields if not isinstance(self_type, list) else None, @@ -381,7 +381,7 @@ def generate_etool_from_expr( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -527,7 +527,7 @@ def empty_inputs( result = {} if isinstance(process_or_step, cwl.Process): for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type) + result[param.id.split("#")[-1]] = example_input(param.type_) else: for param in process_or_step.in_: param_id = param.id.split("/")[-1] @@ -681,7 +681,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.InputParameter( id=None, - type="string", + type_="string", ) etool_id = ( "_expression_workflow_EnvVarRequirement_{}".format( @@ -710,7 +710,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type="long") + target = cwl.InputParameter(id=None, type_="long") etool_id = ( "_expression_workflow_ResourceRequirement_{}".format( attr @@ -739,7 +739,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.InputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -765,7 +765,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.InputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -808,7 +808,7 @@ def process_workflow_reqs_and_hints( ): target = cwl.InputParameter( id=None, - type=expr_result["class"], + type_=expr_result["class"], ) replace_expr_with_etool( expr, @@ -829,7 +829,7 @@ def process_workflow_reqs_and_hints( elif isinstance(expr_result, str): target = cwl.InputParameter( id=None, - type=["File"], + type_=["File"], ) if entry.entryname is None: raise SourceLine( @@ -872,7 +872,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.InputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( index @@ -1002,7 +1002,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type="string") + target = cwl.InputParameter(id=None, type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1026,7 +1026,7 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.InputParameter(id=None, type="long") + target = cwl.InputParameter(id=None, type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) @@ -1053,7 +1053,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.InputParameter(id=None, type=target_type) + target = cwl.InputParameter(id=None, type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1091,7 +1091,7 @@ def process_level_reqs( ) target = cwl.InputParameter( id=None, - type=target_type, + type_=target_type, ) etool_id = ( "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1148,7 +1148,7 @@ def process_level_reqs( d_target_type = ["File", "Directory"] target = cwl.InputParameter( id=None, - type=d_target_type, + type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1178,7 +1178,7 @@ def process_level_reqs( modified = True target = cwl.InputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1223,7 +1223,7 @@ def add_input_to_process( process.inputs.append( cwl.CommandInputParameter( id=name, - type=inptype, + type_=inptype, loadingOptions=loadingOptions, ) ) @@ -1254,7 +1254,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.InputParameter(id=None, type=target_type) + target = cwl.InputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1264,7 +1264,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1280,7 +1280,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.InputParameter(id=None, type=target_type) + target = cwl.InputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1290,7 +1290,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1306,13 +1306,13 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.InputParameter(id=None, type=target_type) + target = cwl.InputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=target_type) + cwl.CommandInputParameter(id=inp_id, type_=target_type) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1320,7 +1320,7 @@ def traverse_CommandLineTool( for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( - inp.inputBinding.valueFrom, inputs, example_input(inp.type) + inp.inputBinding.valueFrom, inputs, example_input(inp.type_) ) if expression: modified = True @@ -1332,7 +1332,7 @@ def traverse_CommandLineTool( ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=inp.type) + cwl.CommandInputParameter(id=inp_id, type_=inp.type_) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1346,7 +1346,7 @@ def traverse_CommandLineTool( inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.InputParameter(id=None, type=glob_target_type) + target = cwl.InputParameter(id=None, type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1354,7 +1354,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=glob_target_type, + type_=glob_target_type, ) ) step.in_.append( @@ -1384,13 +1384,13 @@ def traverse_CommandLineTool( ) self_type = cwl.InputParameter( id=None, - type=cwl.InputArraySchema("File", "array", None, None), + type_=cwl.InputArraySchema("File", "array", None, None), ) etool = generate_etool_from_expr( expression, outp, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( loadContents=True ) etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) @@ -1441,16 +1441,16 @@ def traverse_CommandLineTool( cwl.ExpressionToolOutputParameter, ), ): - new_outp.type = cwl.OutputArraySchema( - items="File", type="array" + new_outp.type_ = cwl.OutputArraySchema( + items="File", type_="array" ) elif isinstance(new_outp, cwl.CommandOutputParameter): if new_outp.outputBinding: new_outp.outputBinding.outputEval = None new_outp.outputBinding.loadContents = None - new_outp.type = cwl.CommandOutputArraySchema( + new_outp.type_ = cwl.CommandOutputArraySchema( items="File", - type="array", + type_="array", ) else: raise Exception( @@ -1645,7 +1645,7 @@ def cltool_inputs_to_etool_inputs( doc=clt_inp.doc, format=clt_inp.format, default=clt_inp.default, - type=clt_inp.type, + type_=clt_inp.type_, extension_fields=clt_inp.extension_fields, loadingOptions=clt_inp.loadingOptions, ) @@ -1683,7 +1683,7 @@ def cltool_step_outputs_to_workflow_outputs( doc=clt_out.doc, format=clt_out.format, outputSource=outputSource, - type=clt_out.type, + type_=clt_out.type_, extension_fields=clt_out.extension_fields, loadingOptions=clt_out.loadingOptions, ) @@ -1711,7 +1711,7 @@ def generate_etool_from_expr2( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, ) ) expression = "${" @@ -1789,9 +1789,9 @@ def traverse_step( ) if isinstance(scattered_source_type, list): for stype in scattered_source_type: - self.append(example_input(stype.type)) + self.append(example_input(stype.type_)) else: - self.append(example_input(scattered_source_type.type)) + self.append(example_input(scattered_source_type.type_)) else: if not step.scatter: self = example_input( @@ -1802,9 +1802,9 @@ def traverse_step( parent, inp.source ) if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type) + self = example_input(scattered_source_type2[0].type_) else: - self = example_input(scattered_source_type2.type) + self = example_input(scattered_source_type2.type_) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1835,7 +1835,7 @@ def traverse_step( source_types.append(temp_type) source_type = cwl.InputParameter( id=None, - type=cwl.ArraySchema(source_types, "array"), + type_=cwl.ArraySchema(source_types, "array"), ) else: input_source_id = inp.source.split("#")[-1] @@ -1915,20 +1915,20 @@ def workflow_step_to_InputParameters( ) if isinstance(param, list): for p in param: - if not p.type: + if not p.type_: raise WorkflowException( f"Don't know how to get type id for {p!r}." ) p.id = inp_id - p.type = clean_type_ids(p.type) + p.type_ = clean_type_ids(p.type_) params.append(p) else: - if not param.type: + if not param.type_: raise WorkflowException( f"Don't know how to get type id for {param!r}." ) param.id = inp_id - param.type = clean_type_ids(param.type) + param.type_ = clean_type_ids(param.type_) params.append(param) return params @@ -1954,7 +1954,7 @@ def replace_step_valueFrom_expr_with_etool( original_step_ins, workflow, step_inp_id ) if source: - source_param = cwl.InputParameter(id="self", type="Any") + source_param = cwl.InputParameter(id="self", type_="Any") # TODO: would be nicer to derive a proper type; but in the face of linkMerge, this is easier for now etool_inputs.append(source_param) temp_etool = generate_etool_from_expr2( diff --git a/cwl_utils/cwl_v1_1_expression_refactor.py b/cwl_utils/cwl_v1_1_expression_refactor.py index 195039ff..801df8fc 100755 --- a/cwl_utils/cwl_v1_1_expression_refactor.py +++ b/cwl_utils/cwl_v1_1_expression_refactor.py @@ -35,7 +35,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool return process result = None for index, output in enumerate(process.outputs): - if output.type == "stdout": # TODO: add 'stdin' for CWL v1.1 + if output.type_ == "stdout": # TODO: add 'stdin' for CWL v1.1 if not result: result = copy.deepcopy(process) stdout_path = process.stdout @@ -46,7 +46,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool ).hexdigest() ) result.stdout = stdout_path - result.outputs[index].type = "File" + result.outputs[index].type_ = "File" output.outputBinding = cwl.CommandOutputBinding(stdout_path, None, None) if result: return result @@ -156,7 +156,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -171,7 +171,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -244,7 +244,7 @@ def traverse( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -262,7 +262,7 @@ def traverse( doc=outp.doc, format=outp.format, outputSource=f"main/{outp_id}", - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -346,9 +346,9 @@ def generate_etool_from_expr( new_type: Union[ List[Union[cwl.ArraySchema, cwl.InputRecordSchema]], Union[cwl.ArraySchema, cwl.InputRecordSchema], - ] = [clean_type_ids(t.type) for t in self_type] + ] = [clean_type_ids(t.type_) for t in self_type] else: - new_type = clean_type_ids(self_type.type) + new_type = clean_type_ids(self_type.type_) inputs.append( cwl.WorkflowInputParameter( id="self", @@ -361,7 +361,7 @@ def generate_etool_from_expr( else None, doc=self_type.doc if not isinstance(self_type, list) else None, format=self_type.format if not isinstance(self_type, list) else None, - type=new_type, + type_=new_type, extension_fields=self_type.extension_fields if not isinstance(self_type, list) else None, @@ -379,7 +379,7 @@ def generate_etool_from_expr( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -525,7 +525,7 @@ def empty_inputs( result = {} if isinstance(process_or_step, cwl.Process): for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type) + result[param.id.split("#")[-1]] = example_input(param.type_) else: for param in process_or_step.in_: param_id = param.id.split("/")[-1] @@ -681,7 +681,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = ( "_expression_workflow_EnvVarRequirement_{}".format( @@ -710,7 +710,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="long") + target = cwl.WorkflowInputParameter(id=None, type_="long") etool_id = ( "_expression_workflow_ResourceRequirement_{}".format( attr @@ -739,7 +739,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -765,7 +765,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -808,7 +808,7 @@ def process_workflow_reqs_and_hints( ): target = cwl.WorkflowInputParameter( id=None, - type=expr_result["class"], + type_=expr_result["class"], ) replace_expr_with_etool( expr, @@ -829,7 +829,7 @@ def process_workflow_reqs_and_hints( elif isinstance(expr_result, str): target = cwl.WorkflowInputParameter( id=None, - type=["File"], + type_=["File"], ) if entry.entryname is None: raise SourceLine( @@ -872,7 +872,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( index @@ -1002,7 +1002,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="string") + target = cwl.WorkflowInputParameter(id=None, type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1026,7 +1026,7 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="long") + target = cwl.WorkflowInputParameter(id=None, type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) @@ -1053,7 +1053,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1091,7 +1091,7 @@ def process_level_reqs( ) target = cwl.WorkflowInputParameter( id=None, - type=target_type, + type_=target_type, ) etool_id = ( "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1148,7 +1148,7 @@ def process_level_reqs( d_target_type = ["File", "Directory"] target = cwl.WorkflowInputParameter( id=None, - type=d_target_type, + type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1178,7 +1178,7 @@ def process_level_reqs( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1223,7 +1223,7 @@ def add_input_to_process( process.inputs.append( cwl.CommandInputParameter( id=name, - type=inptype, + type_=inptype, loadingOptions=loadingOptions, ) ) @@ -1254,7 +1254,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1264,7 +1264,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1280,7 +1280,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1290,7 +1290,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1306,13 +1306,13 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=target_type) + cwl.CommandInputParameter(id=inp_id, type_=target_type) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1320,7 +1320,7 @@ def traverse_CommandLineTool( for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( - inp.inputBinding.valueFrom, inputs, example_input(inp.type) + inp.inputBinding.valueFrom, inputs, example_input(inp.type_) ) if expression: modified = True @@ -1332,7 +1332,7 @@ def traverse_CommandLineTool( ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=inp.type) + cwl.CommandInputParameter(id=inp_id, type_=inp.type_) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1346,7 +1346,7 @@ def traverse_CommandLineTool( inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.WorkflowInputParameter(id=None, type=glob_target_type) + target = cwl.WorkflowInputParameter(id=None, type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1354,7 +1354,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=glob_target_type, + type_=glob_target_type, ) ) step.in_.append( @@ -1384,13 +1384,13 @@ def traverse_CommandLineTool( ) self_type = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema("File", "array", None, None), + type_=cwl.InputArraySchema("File", "array", None, None), ) etool = generate_etool_from_expr( expression, outp, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( loadContents=True ) etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) @@ -1441,16 +1441,16 @@ def traverse_CommandLineTool( cwl.ExpressionToolOutputParameter, ), ): - new_outp.type = cwl.OutputArraySchema( - items="File", type="array" + new_outp.type_ = cwl.OutputArraySchema( + items="File", type_="array" ) elif isinstance(new_outp, cwl.CommandOutputParameter): if new_outp.outputBinding: new_outp.outputBinding.outputEval = None new_outp.outputBinding.loadContents = None - new_outp.type = cwl.CommandOutputArraySchema( + new_outp.type_ = cwl.CommandOutputArraySchema( items="File", - type="array", + type_="array", ) else: raise Exception( @@ -1645,7 +1645,7 @@ def cltool_inputs_to_etool_inputs( doc=clt_inp.doc, format=clt_inp.format, default=clt_inp.default, - type=clt_inp.type, + type_=clt_inp.type_, extension_fields=clt_inp.extension_fields, loadingOptions=clt_inp.loadingOptions, ) @@ -1683,7 +1683,7 @@ def cltool_step_outputs_to_workflow_outputs( doc=clt_out.doc, format=clt_out.format, outputSource=outputSource, - type=clt_out.type, + type_=clt_out.type_, extension_fields=clt_out.extension_fields, loadingOptions=clt_out.loadingOptions, ) @@ -1711,7 +1711,7 @@ def generate_etool_from_expr2( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, ) ) expression = "${" @@ -1789,9 +1789,9 @@ def traverse_step( ) if isinstance(scattered_source_type, list): for stype in scattered_source_type: - self.append(example_input(stype.type)) + self.append(example_input(stype.type_)) else: - self.append(example_input(scattered_source_type.type)) + self.append(example_input(scattered_source_type.type_)) else: if not step.scatter: self = example_input( @@ -1802,9 +1802,9 @@ def traverse_step( parent, inp.source ) if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type) + self = example_input(scattered_source_type2[0].type_) else: - self = example_input(scattered_source_type2.type) + self = example_input(scattered_source_type2.type_) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1835,7 +1835,7 @@ def traverse_step( source_types.append(temp_type) source_type = cwl.WorkflowInputParameter( id=None, - type=cwl.ArraySchema(source_types, "array"), + type_=cwl.ArraySchema(source_types, "array"), ) else: input_source_id = inp.source.split("#")[-1] @@ -1916,11 +1916,11 @@ def workflow_step_to_WorkflowInputParameters( if isinstance(param, list): for p in param: p.id = inp_id - p.type = clean_type_ids(p.type) + p.type_ = clean_type_ids(p.type_) params.append(p) else: param.id = inp_id - param.type = clean_type_ids(param.type) + param.type_ = clean_type_ids(param.type_) params.append(param) return params @@ -1948,7 +1948,7 @@ def replace_step_valueFrom_expr_with_etool( original_step_ins, workflow, step_inp_id ) if source: - source_param = cwl.WorkflowInputParameter(id="self", type="Any") + source_param = cwl.WorkflowInputParameter(id="self", type_="Any") # TODO: would be nicer to derive a proper type; but in the face of linkMerge, this is easier for now etool_inputs.append(source_param) temp_etool = generate_etool_from_expr2( diff --git a/cwl_utils/cwl_v1_2_expression_refactor.py b/cwl_utils/cwl_v1_2_expression_refactor.py index a7928fa5..7f7d2dc3 100755 --- a/cwl_utils/cwl_v1_2_expression_refactor.py +++ b/cwl_utils/cwl_v1_2_expression_refactor.py @@ -35,7 +35,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool return process result = None for index, output in enumerate(process.outputs): - if output.type == "stdout": # TODO: add 'stdin' for CWL v1.1 + if output.type_ == "stdout": # TODO: add 'stdin' for CWL v1.1 if not result: result = copy.deepcopy(process) stdout_path = process.stdout @@ -46,7 +46,7 @@ def expand_stream_shortcuts(process: cwl.CommandLineTool) -> cwl.CommandLineTool ).hexdigest() ) result.stdout = stdout_path - result.outputs[index].type = "File" + result.outputs[index].type_ = "File" output.outputBinding = cwl.CommandOutputBinding(stdout_path, None, None) if result: return result @@ -156,7 +156,7 @@ def etool_to_cltool( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -171,7 +171,7 @@ def etool_to_cltool( streamable=outp.streamable, doc=outp.doc, format=outp.format, - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -244,7 +244,7 @@ def traverse( doc=inp.doc, format=inp.format, default=inp.default, - type=inp.type, + type_=inp.type_, extension_fields=inp.extension_fields, loadingOptions=inp.loadingOptions, ) @@ -262,7 +262,7 @@ def traverse( doc=outp.doc, format=outp.format, outputSource=f"main/{outp_id}", - type=outp.type, + type_=outp.type_, extension_fields=outp.extension_fields, loadingOptions=outp.loadingOptions, ) @@ -346,9 +346,9 @@ def generate_etool_from_expr( new_type: Union[ List[Union[cwl.ArraySchema, cwl.InputRecordSchema]], Union[cwl.ArraySchema, cwl.InputRecordSchema], - ] = [clean_type_ids(t.type) for t in self_type] + ] = [clean_type_ids(t.type_) for t in self_type] else: - new_type = clean_type_ids(self_type.type) + new_type = clean_type_ids(self_type.type_) inputs.append( cwl.WorkflowInputParameter( id="self", @@ -361,7 +361,7 @@ def generate_etool_from_expr( else None, doc=self_type.doc if not isinstance(self_type, list) else None, format=self_type.format if not isinstance(self_type, list) else None, - type=new_type, + type_=new_type, extension_fields=self_type.extension_fields if not isinstance(self_type, list) else None, @@ -379,7 +379,7 @@ def generate_etool_from_expr( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, extension_fields=target.extension_fields, loadingOptions=target.loadingOptions, ) @@ -525,7 +525,7 @@ def empty_inputs( result = {} if isinstance(process_or_step, cwl.Process): for param in process_or_step.inputs: - result[param.id.split("#")[-1]] = example_input(param.type) + result[param.id.split("#")[-1]] = example_input(param.type_) else: for param in process_or_step.in_: param_id = param.id.split("/")[-1] @@ -697,10 +697,10 @@ def process_workflow_inputs_and_outputs( etool_id = "_pickValue_workflow_step_{}".format( param2.id.split("#")[-1] ) - target_type = copy.deepcopy(param2.type) + target_type = copy.deepcopy(param2.type_) if isinstance(target_type, cwl.OutputArraySchema): target_type.name = None - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) if not isinstance(param2.outputSource, list): sources = param2.outputSource.split("#")[-1] else: @@ -717,7 +717,7 @@ def process_workflow_inputs_and_outputs( source_type_items.append("null") elif source_type_items != "null": source_type_items = ["null", source_type_items] - source_type = cwl.CommandInputParameter(type=source_type_items) + source_type = cwl.CommandInputParameter(type_=source_type_items) replace_expr_with_etool( expression, etool_id, @@ -776,7 +776,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = ( "_expression_workflow_EnvVarRequirement_{}".format( @@ -805,7 +805,7 @@ def process_workflow_reqs_and_hints( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="long") + target = cwl.WorkflowInputParameter(id=None, type_="long") etool_id = ( "_expression_workflow_ResourceRequirement_{}".format( attr @@ -834,7 +834,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -860,7 +860,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema( + type_=cwl.InputArraySchema( ["File", "Directory"], "array", None, None ), ) @@ -903,7 +903,7 @@ def process_workflow_reqs_and_hints( ): target = cwl.WorkflowInputParameter( id=None, - type=expr_result["class"], + type_=expr_result["class"], ) replace_expr_with_etool( expr, @@ -924,7 +924,7 @@ def process_workflow_reqs_and_hints( elif isinstance(expr_result, str): target = cwl.WorkflowInputParameter( id=None, - type=["File"], + type_=["File"], ) if entry.entryname is None: raise SourceLine( @@ -967,7 +967,7 @@ def process_workflow_reqs_and_hints( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_workflow_InitialWorkDirRequirement_{}".format( index @@ -1097,7 +1097,7 @@ def process_level_reqs( expression = get_expression(envDef.envValue, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="string") + target = cwl.WorkflowInputParameter(id=None, type_="string") etool_id = "_expression_{}_EnvVarRequirement_{}".format( step_name, env_index ) @@ -1121,7 +1121,7 @@ def process_level_reqs( expression = get_expression(this_attr, inputs, None) if expression: modified = True - target = cwl.WorkflowInputParameter(id=None, type="long") + target = cwl.WorkflowInputParameter(id=None, type_="long") etool_id = "_expression_{}_ResourceRequirement_{}".format( step_name, attr ) @@ -1148,7 +1148,7 @@ def process_level_reqs( target_type = cwl.InputArraySchema( ["File", "Directory"], "array", None, None ) - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) etool_id = "_expression_{}_InitialWorkDirRequirement".format( step_name ) @@ -1186,7 +1186,7 @@ def process_level_reqs( ) target = cwl.WorkflowInputParameter( id=None, - type=target_type, + type_=target_type, ) etool_id = ( "_expression_{}_InitialWorkDirRequirement_{}".format( @@ -1243,7 +1243,7 @@ def process_level_reqs( d_target_type = ["File", "Directory"] target = cwl.WorkflowInputParameter( id=None, - type=d_target_type, + type_=d_target_type, ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1273,7 +1273,7 @@ def process_level_reqs( modified = True target = cwl.WorkflowInputParameter( id=None, - type="string", + type_="string", ) etool_id = "_expression_{}_InitialWorkDirRequirement_{}".format( step_name, listing_index @@ -1318,7 +1318,7 @@ def add_input_to_process( process.inputs.append( cwl.CommandInputParameter( id=name, - type=inptype, + type_=inptype, loadingOptions=loadingOptions, ) ) @@ -1349,7 +1349,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1359,7 +1359,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1375,7 +1375,7 @@ def traverse_CommandLineTool( inp_id = f"_arguments_{index}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "Any" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1385,7 +1385,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=target_type, + type_=target_type, ) ) step.in_.append( @@ -1401,13 +1401,13 @@ def traverse_CommandLineTool( inp_id = f"_{streamtype}" etool_id = f"_expression_{step_id}{inp_id}" target_type = "string" - target = cwl.WorkflowInputParameter(id=None, type=target_type) + target = cwl.WorkflowInputParameter(id=None, type_=target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) setattr(target_clt, streamtype, f"$(inputs.{inp_id})") target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=target_type) + cwl.CommandInputParameter(id=inp_id, type_=target_type) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1415,7 +1415,7 @@ def traverse_CommandLineTool( for inp in clt.inputs: if not skip_command_line1 and inp.inputBinding and inp.inputBinding.valueFrom: expression = get_expression( - inp.inputBinding.valueFrom, inputs, example_input(inp.type) + inp.inputBinding.valueFrom, inputs, example_input(inp.type_) ) if expression: modified = True @@ -1427,7 +1427,7 @@ def traverse_CommandLineTool( ) inp.inputBinding.valueFrom = f"$(inputs.{inp_id})" target_clt.inputs.append( - cwl.CommandInputParameter(id=inp_id, type=inp.type) + cwl.CommandInputParameter(id=inp_id, type_=inp.type_) ) step.in_.append( cwl.WorkflowStepInput(id=inp_id, source=f"{etool_id}/result") @@ -1441,7 +1441,7 @@ def traverse_CommandLineTool( inp_id = "_{}_glob".format(outp.id.split("#")[-1]) etool_id = f"_expression_{step_id}{inp_id}" glob_target_type = ["string", cwl.ArraySchema("string", "array")] - target = cwl.WorkflowInputParameter(id=None, type=glob_target_type) + target = cwl.WorkflowInputParameter(id=None, type_=glob_target_type) replace_step_clt_expr_with_etool( expression, etool_id, parent, target, step, replace_etool ) @@ -1449,7 +1449,7 @@ def traverse_CommandLineTool( target_clt.inputs.append( cwl.CommandInputParameter( id=inp_id, - type=glob_target_type, + type_=glob_target_type, ) ) step.in_.append( @@ -1479,13 +1479,13 @@ def traverse_CommandLineTool( ) self_type = cwl.WorkflowInputParameter( id=None, - type=cwl.InputArraySchema("File", "array", None, None), + type_=cwl.InputArraySchema("File", "array", None, None), ) etool = generate_etool_from_expr( expression, outp, False, self_type, [clt, step, parent] ) if outp.outputBinding.loadContents: - etool.inputs[0].type.inputBinding = cwl.CommandLineBinding( + etool.inputs[0].type_.inputBinding = cwl.CommandLineBinding( loadContents=True ) etool.inputs.extend(cltool_inputs_to_etool_inputs(clt)) @@ -1536,16 +1536,16 @@ def traverse_CommandLineTool( cwl.ExpressionToolOutputParameter, ), ): - new_outp.type = cwl.OutputArraySchema( - items="File", type="array" + new_outp.type_ = cwl.OutputArraySchema( + items="File", type_="array" ) elif isinstance(new_outp, cwl.CommandOutputParameter): if new_outp.outputBinding: new_outp.outputBinding.outputEval = None new_outp.outputBinding.loadContents = None - new_outp.type = cwl.CommandOutputArraySchema( + new_outp.type_ = cwl.CommandOutputArraySchema( items="File", - type="array", + type_="array", ) else: raise Exception( @@ -1740,7 +1740,7 @@ def cltool_inputs_to_etool_inputs( doc=clt_inp.doc, format=clt_inp.format, default=clt_inp.default, - type=clt_inp.type, + type_=clt_inp.type_, extension_fields=clt_inp.extension_fields, loadingOptions=clt_inp.loadingOptions, ) @@ -1778,7 +1778,7 @@ def cltool_step_outputs_to_workflow_outputs( doc=clt_out.doc, format=clt_out.format, outputSource=outputSource, - type=clt_out.type, + type_=clt_out.type_, extension_fields=clt_out.extension_fields, loadingOptions=clt_out.loadingOptions, ) @@ -1806,7 +1806,7 @@ def generate_etool_from_expr2( streamable=target.streamable, doc=target.doc, format=target.format, - type=target.type, + type_=target.type_, ) ) expression = "${" @@ -1884,9 +1884,9 @@ def traverse_step( ) if isinstance(scattered_source_type, list): for stype in scattered_source_type: - self.append(example_input(stype.type)) + self.append(example_input(stype.type_)) else: - self.append(example_input(scattered_source_type.type)) + self.append(example_input(scattered_source_type.type_)) else: if not step.scatter: self = example_input( @@ -1897,9 +1897,9 @@ def traverse_step( parent, inp.source ) if isinstance(scattered_source_type2, list): - self = example_input(scattered_source_type2[0].type) + self = example_input(scattered_source_type2[0].type_) else: - self = example_input(scattered_source_type2.type) + self = example_input(scattered_source_type2.type_) expression = get_expression(inp.valueFrom, inputs, self) if expression: modified = True @@ -1930,7 +1930,7 @@ def traverse_step( source_types.append(temp_type) source_type = cwl.WorkflowInputParameter( id=None, - type=cwl.ArraySchema(source_types, "array"), + type_=cwl.ArraySchema(source_types, "array"), ) else: input_source_id = inp.source.split("#")[-1] @@ -2019,11 +2019,11 @@ def workflow_step_to_WorkflowInputParameters( if isinstance(param, list): for p in param: p.id = inp_id - p.type = clean_type_ids(p.type) + p.type_ = clean_type_ids(p.type_) params.append(p) else: param.id = inp_id - param.type = clean_type_ids(param.type) + param.type_ = clean_type_ids(param.type_) params.append(param) return params @@ -2051,7 +2051,7 @@ def replace_step_valueFrom_expr_with_etool( original_step_ins, workflow, step_inp_id ) if source: - source_param = cwl.WorkflowInputParameter(id="self", type="Any") + source_param = cwl.WorkflowInputParameter(id="self", type_="Any") # TODO: would be nicer to derive a proper type; but in the face of linkMerge, this is easier for now etool_inputs.append(source_param) temp_etool = generate_etool_from_expr2( @@ -2130,7 +2130,7 @@ def replace_step_when_expr_with_etool( ) temp_etool = generate_etool_from_expr2( expr, - cwl.WorkflowInputParameter(id=None, type="boolean"), + cwl.WorkflowInputParameter(id=None, type_="boolean"), etool_inputs, None, None, diff --git a/cwl_utils/parser/cwl_v1_0.py b/cwl_utils/parser/cwl_v1_0.py index c64fcdd9..2d1c6e0d 100644 --- a/cwl_utils/parser/cwl_v1_0.py +++ b/cwl_utils/parser/cwl_v1_0.py @@ -11,6 +11,7 @@ import xml.sax # nosec from abc import ABC, abstractmethod from io import StringIO +from itertools import chain from typing import ( Any, Dict, @@ -59,6 +60,8 @@ class LoadingOptions: cache: CacheType imports: List[str] includes: List[str] + no_link_check: Optional[bool] + container: Optional[str] def __init__( self, @@ -73,6 +76,8 @@ def __init__( idx: Optional[IdxType] = None, imports: Optional[List[str]] = None, includes: Optional[List[str]] = None, + no_link_check: Optional[bool] = None, + container: Optional[str] = None, ) -> None: """Create a LoadingOptions object.""" self.original_doc = original_doc @@ -117,6 +122,16 @@ def __init__( else: self.includes = copyfrom.includes if copyfrom is not None else [] + if no_link_check is not None: + self.no_link_check = no_link_check + else: + self.no_link_check = copyfrom.no_link_check if copyfrom is not None else False + + if container is not None: + self.container = container + else: + self.container = copyfrom.container if copyfrom is not None else None + if fetcher is not None: self.fetcher = fetcher elif copyfrom is not None: @@ -138,10 +153,10 @@ def __init__( self.vocab = _vocab self.rvocab = _rvocab - if namespaces is not None: + if self.namespaces is not None: self.vocab = self.vocab.copy() self.rvocab = self.rvocab.copy() - for k, v in namespaces.items(): + for k, v in self.namespaces.items(): self.vocab[k] = v self.rvocab[v] = k @@ -204,8 +219,14 @@ def save( """Convert this object to a JSON/YAML friendly dictionary.""" -def load_field(val, fieldtype, baseuri, loadingOptions): - # type: (Union[str, Dict[str, str]], _Loader, str, LoadingOptions) -> Any +def load_field( + val: Union[str, Dict[str, str]], + fieldtype: "_Loader", + baseuri: str, + loadingOptions: LoadingOptions, + lc: Optional[List[Any]] = None, +) -> Any: + """Load field.""" if isinstance(val, MutableMapping): if "$import" in val: if loadingOptions.fileuri is None: @@ -224,12 +245,69 @@ def load_field(val, fieldtype, baseuri, loadingOptions): url = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) val = loadingOptions.fetcher.fetch_text(url) loadingOptions.includes.append(url) - return fieldtype.load(val, baseuri, loadingOptions) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] +def extract_type(val_type: Type[Any]) -> str: + """Take a type of value, and extracts the value as a string.""" + val_str = str(val_type) + return val_str.split("'")[1] + + +def convert_typing(val_type: str) -> str: + """Normalize type names to schema-salad types.""" + if "None" in val_type: + return "null" + if "CommentedSeq" in val_type or "list" in val_type: + return "array" + if "CommentedMap" in val_type or "dict" in val_type: + return "object" + if "False" in val_type or "True" in val_type: + return "boolean" + return val_type + + +def parse_errors(error_message: str) -> Tuple[str, str, str]: + """Parse error messages from several loaders into one error message.""" + if not error_message.startswith("Expected"): + return error_message, "", "" + vals = error_message.split("\n") + if len(vals) == 1: + return error_message, "", "" + types = set() + for val in vals: + individual_vals = val.split(" ") + if val == "": + continue + if individual_vals[1] == "one": + individual_vals = val.split("(")[1].split(",") + for t in individual_vals: + types.add(t.strip(" ").strip(")\n")) + elif individual_vals[2] == "").replace("'", "")) + elif individual_vals[0] == "Value": + types.add(individual_vals[-1].strip(".")) + else: + types.add(individual_vals[1].replace(",", "")) + types = set(val for val in types if val != "NoneType") + if "str" in types: + types = set(convert_typing(val) for val in types if "'" not in val) + to_print = "" + for val in types: + if "'" in val: + to_print = "value" if len(types) == 1 else "values" + + if to_print == "": + to_print = "type" if len(types) == 1 else "types" + + verb_tensage = "is" if len(types) == 1 else "are" + + return str(types).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage + + def save( val: Any, top: bool = True, @@ -279,14 +357,13 @@ def save_with_metadata( def expand_url( - url, # type: str - base_url, # type: str - loadingOptions, # type: LoadingOptions - scoped_id=False, # type: bool - vocab_term=False, # type: bool - scoped_ref=None, # type: Optional[int] -): - # type: (...) -> str + url: str, + base_url: str, + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: Optional[int] = None, +) -> str: if url in ("@id", "@type"): return url @@ -347,88 +424,186 @@ def expand_url( class _Loader: - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: pass class _AnyLoader(_Loader): - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") class _PrimitiveLoader(_Loader): - def __init__(self, tp): - # type: (Union[type, Tuple[Type[str], Type[str]]]) -> None + def __init__(self, tp: Union[type, Tuple[Type[str], Type[str]]]) -> None: self.tp = tp - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, self.tp): raise ValidationException( - "Expected a {} but got {}".format( - self.tp.__class__.__name__, doc.__class__.__name__ - ) + "Expected a {} but got {}".format(self.tp, doc.__class__.__name__) ) return doc - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.tp) class _ArrayLoader(_Loader): - def __init__(self, items): - # type: (_Loader) -> None + def __init__(self, items: _Loader) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableSequence): - raise ValidationException(f"Expected a list, was {type(doc)}") - r = [] # type: List[Any] - errors = [] # type: List[SchemaSaladException] + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an array." + ) + r: List[Any] = [] + errors: List[SchemaSaladException] = [] + fields: List[str] = [] for i in range(0, len(doc)): try: - lf = load_field(doc[i], _UnionLoader((self, self.items)), baseuri, loadingOptions) - if isinstance(lf, MutableSequence): + lf = load_field( + doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc + ) + flatten = loadingOptions.container != "@list" + if flatten and isinstance(lf, MutableSequence): r.extend(lf) else: r.append(lf) + + if isinstance(doc[i], CommentedMap): + if doc[i].get("id") is not None: + if doc[i].get("id") in fields: + errors.append( + ValidationException( + f"Duplicate field {doc[i].get('id')!r}", + SourceLine(doc[i], "id", str), + [], + ) + ) + else: + fields.append(doc[i].get("id")) + except ValidationException as e: - errors.append(e.with_sourceline(SourceLine(doc, i, str))) + e = ValidationException( + "array item is invalid because", SourceLine(doc, i, str), [e] + ) + errors.append(e) if errors: raise ValidationException("", None, errors) return r - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return f"array<{self.items}>" +class _MapLoader(_Loader): + def __init__( + self, + values: _Loader, + name: Optional[str] = None, + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: + self.values = values + self.name = name + self.container = container + self.no_link_check = no_link_check + + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if not isinstance(doc, MutableMapping): + raise ValidationException(f"Expected a map, was {type(doc)}") + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) + r: Dict[str, Any] = {} + errors: List[SchemaSaladException] = [] + for k, v in doc.items(): + try: + lf = load_field(v, self.values, baseuri, loadingOptions, lc) + r[k] = lf + except ValidationException as e: + errors.append(e.with_sourceline(SourceLine(doc, k, str))) + if errors: + raise ValidationException("", None, errors) + return r + + def __repr__(self) -> str: + return self.name if self.name is not None else f"map" + + class _EnumLoader(_Loader): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols = symbols self.name = name - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc in self.symbols: return doc raise ValidationException(f"Expected one of {self.symbols}") - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return self.name class _SecondaryDSLLoader(_Loader): - def __init__(self, inner): - # type: (_Loader) -> None + def __init__(self, inner: _Loader) -> None: self.inner = inner - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: r: List[Dict[str, Any]] = [] if isinstance(doc, MutableSequence): for d in doc: @@ -486,21 +661,40 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): r.append({"pattern": doc}) else: raise ValidationException("Expected str or sequence of str") - return self.inner.load(r, baseuri, loadingOptions, docRoot) + return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) class _RecordLoader(_Loader): - def __init__(self, classtype): - # type: (Type[Saveable]) -> None + def __init__( + self, + classtype: Type[Saveable], + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: self.classtype = classtype + self.container = container + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableMapping): - raise ValidationException(f"Expected a dict, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an object." + ) + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) return self.classtype.fromDoc(doc, baseuri, loadingOptions, docRoot=docRoot) - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.classtype.__name__) @@ -508,41 +702,139 @@ class _ExpressionLoader(_Loader): def __init__(self, items: Type[str]) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, str): - raise ValidationException(f"Expected a str, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is a str." + ) return doc class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader]) -> None: + def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: self.alternates = alternates + self.name = name + + def add_loaders(self, loaders: Sequence[_Loader]) -> None: + self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: errors = [] + + if lc is None: + lc = [] + for t in self.alternates: try: - return t.load(doc, baseuri, loadingOptions, docRoot=docRoot) + return t.load(doc, baseuri, loadingOptions, docRoot=docRoot, lc=lc) except ValidationException as e: - errors.append(ValidationException(f"tried {t} but", None, [e])) - raise ValidationException("", None, errors, "-") + if isinstance(t, _ArrayLoader) and len(self.alternates) > 1: + continue + if isinstance(doc, (CommentedMap, dict)): + if "class" in doc: + if str(doc.get("class")) == str(t): + errors.append( + ValidationException( + f"Object `{baseuri.split('/')[-1]}` is not valid because:", + SourceLine(doc, next(iter(doc)), str), + [e], + ) + ) + else: + if "array" in str(t): + continue + else: + if "id" in doc: + id = baseuri.split("/")[-1] + "#" + str(doc.get("id")) + if "id" in lc: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, "id", str), + [e], + ) + ) + else: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, doc.get("id"), str), + [e], + ) + ) + else: + if not isinstance( + t, (_PrimitiveLoader) + ): # avoids 'tried was {x}' errors + errors.append( + ValidationException(f"tried `{t}` but", None, [e]) + ) + else: + # avoids "tried but x" and instead returns the values for parsing + errors.append(ValidationException("", None, [e])) + + if isinstance(doc, (CommentedMap, dict)) and "class" in doc: + if str(doc.get("class")) not in str(self.alternates): + errors.append( + ValidationException( + "Field `class` contains undefined reference to " + + "`" + + "/".join(baseuri.split("/")[0:-1]) + + "/" + + str(doc.get("class")) + + "`", + SourceLine(doc, "class", str), + [], + ) + ) + raise ValidationException("", None, errors, "*") - def __repr__(self): # type: () -> str - return " | ".join(str(a) for a in self.alternates) + def __repr__(self) -> str: + return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) class _URILoader(_Loader): - def __init__(self, inner, scoped_id, vocab_term, scoped_ref): - # type: (_Loader, bool, bool, Union[int, None]) -> None + def __init__( + self, + inner: _Loader, + scoped_id: bool, + vocab_term: bool, + scoped_ref: Optional[int], + no_link_check: Optional[bool], + ) -> None: self.inner = inner self.scoped_id = scoped_id self.vocab_term = vocab_term self.scoped_ref = scoped_ref + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, no_link_check=self.no_link_check + ) if isinstance(doc, MutableSequence): newdoc = [] for i in doc: @@ -569,23 +861,33 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): self.vocab_term, self.scoped_ref, ) - return self.inner.load(doc, baseuri, loadingOptions) + if isinstance(doc, str): + if not loadingOptions.no_link_check: + errors = [] + try: + if not loadingOptions.fetcher.check_exists(doc): + errors.append( + ValidationException(f"contains undefined reference to `{doc}`") + ) + except ValidationException: + pass + if len(errors) > 0: + raise ValidationException("", None, errors) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _TypeDSLLoader(_Loader): - def __init__(self, inner, refScope, salad_version): - # type: (_Loader, Union[int, None], str) -> None + def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: self.inner = inner self.refScope = refScope self.salad_version = salad_version def resolve( self, - doc, # type: str - baseuri, # type: str - loadingOptions, # type: LoadingOptions - ): - # type: (...) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + doc: str, + baseuri: str, + loadingOptions: LoadingOptions, + ) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str]: doc_ = doc optional = False if doc_.endswith("?"): @@ -594,7 +896,7 @@ def resolve( if doc_.endswith("[]"): salad_versions = [int(v) for v in self.salad_version[1:].split(".")] - items = "" # type: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + items: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] = "" rest = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): @@ -606,7 +908,7 @@ def resolve( items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded = {"type": "array", "items": items} # type: Union[Dict[str, Any], str] + expanded: Union[Dict[str, Any], str] = {"type": "array", "items": items} else: expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) @@ -615,10 +917,16 @@ def resolve( else: return expanded - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableSequence): - r = [] # type: List[Any] + r: List[Any] = [] for d in doc: if isinstance(d, str): resolved = self.resolve(d, baseuri, loadingOptions) @@ -635,20 +943,25 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): elif isinstance(doc, str): doc = self.resolve(doc, baseuri, loadingOptions) - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _IdMapLoader(_Loader): - def __init__(self, inner, mapSubject, mapPredicate): - # type: (_Loader, str, Union[str, None]) -> None + def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: self.inner = inner self.mapSubject = mapSubject self.mapPredicate = mapPredicate - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableMapping): - r = [] # type: List[Any] + r: List[Any] = [] for k in sorted(doc.keys()): val = doc[k] if isinstance(val, CommentedMap): @@ -669,7 +982,7 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): else: raise ValidationException("No mapPredicate") doc = r - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) def _document_load( @@ -706,7 +1019,13 @@ def _document_load( addl_metadata=addl_metadata, ) - doc = {k: v for k, v in doc.items() if k not in ("$namespaces", "$schemas", "$base")} + doc = copy.copy(doc) + if "$namespaces" in doc: + doc.pop("$namespaces") + if "$schemas" in doc: + doc.pop("$schemas") + if "$base" in doc: + doc.pop("$base") if "$graph" in doc: loadingOptions.idx[baseuri] = ( @@ -767,7 +1086,8 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path, split_frag=False): # type: (str, bool) -> str +def file_uri(path: str, split_frag: bool = False) -> str: + """Transform a file path into a URL with file scheme.""" if path.startswith("file://"): return path if split_frag: @@ -845,7 +1165,11 @@ def parser_info() -> str: return "org.w3id.cwl.v1_0" -class RecordField(Saveable): +class Documented(Saveable): + pass + + +class RecordField(Documented): """ A field of a record. """ @@ -853,12 +1177,11 @@ class RecordField(Saveable): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -867,21 +1190,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name self.doc = doc - self.type = type + self.name = name + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordField): return bool( - self.name == other.name - and self.doc == other.doc - and self.type == other.type + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.name, self.doc, self.type)) + return hash((self.doc, self.name, self.type_)) @classmethod def fromDoc( @@ -889,9 +1212,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -900,18 +1224,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -920,46 +1268,101 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: try: doc = load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -967,20 +1370,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `doc`, `type`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, doc=doc, - type=type, + name=name, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1005,9 +1407,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1018,18 +1420,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "doc", "type"]) + attrs = frozenset(["doc", "name", "type"]) class RecordSchema(Saveable): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1039,15 +1440,15 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordSchema): - return bool(self.fields == other.fields and self.type == other.type) + return bool(self.fields == other.fields and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.fields, self.type)) + return hash((self.fields, self.type_)) @classmethod def fromDoc( @@ -1055,9 +1456,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -1069,36 +1471,91 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Record_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1112,13 +1569,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1139,9 +1595,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1164,11 +1620,11 @@ class EnumSchema(Saveable): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1177,16 +1633,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, EnumSchema): - return bool(self.symbols == other.symbols and self.type == other.type) + return bool( + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type)) + return hash((self.name, self.symbols, self.type_)) @classmethod def fromDoc( @@ -1194,47 +1655,157 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None, - baseuri, - loadingOptions, - ) - except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + + symbols = load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") ) - try: - type = load_field( - _doc.get("type"), - typedsl_Enum_symbolLoader_2, - baseuri, - loadingOptions, - ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1242,22 +1813,23 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -1271,12 +1843,15 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u if self.symbols is not None: - u = save_relative_uri(self.symbols, base_url, True, None, relative_uris) + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1287,18 +1862,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type"]) + attrs = frozenset(["name", "symbols", "type"]) class ArraySchema(Saveable): def __init__( self, items: Any, - type: Any, + type_: Any, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1308,15 +1882,15 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type == other.type) + return bool(self.items == other.items and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.items, self.type)) + return hash((self.items, self.type_)) @classmethod def fromDoc( @@ -1324,47 +1898,1104 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2, + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class MapSchema(Saveable): + def __init__( + self, + type_: Any, + values: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.type_ = type_ + self.values = values + + def __eq__(self, other: Any) -> bool: + if isinstance(other, MapSchema): + return bool(self.type_ == other.type_ and self.values == other.values) + return False + + def __hash__(self) -> int: + return hash((self.type_, self.values)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "MapSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Map_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + try: + if _doc.get("values") is None: + raise ValidationException("missing required field `values`", None, []) + + values = load_field( + _doc.get("values"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("values") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `values`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("values")))) + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `type`, `values`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + type_=type_, + values=values, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.values is not None: + u = save_relative_uri(self.values, base_url, False, 2, relative_uris) + r["values"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["type", "values"]) + + +class UnionSchema(Saveable): + def __init__( + self, + names: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.names = names + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, UnionSchema): + return bool(self.names == other.names and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.names, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "UnionSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("names") is None: + raise ValidationException("missing required field `names`", None, []) + + names = load_field( + _doc.get("names"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("names") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `names`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("names")))) + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Union_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `names`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + names=names, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.names is not None: + u = save_relative_uri(self.names, base_url, False, 2, relative_uris) + r["names"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["names", "type"]) + + +class CWLArraySchema(ArraySchema): + def __init__( + self, + items: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLArraySchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class CWLRecordField(RecordField): + def __init__( + self, + name: Any, + type_: Any, + doc: Optional[Any] = None, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + ) + return False + + def __hash__(self) -> int: + return hash((self.doc, self.name, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLRecordField": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + _errors__.append(ValidationException("missing name")) + if not __original_name_is_none: + baseuri = name + if "doc" in _doc: + try: + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) + else: + doc = None + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + doc=doc, + name=name, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["doc", "name", "type"]) + + +class CWLRecordSchema(RecordSchema): + def __init__( + self, + type_: Any, + fields: Optional[Any] = None, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.fields = fields + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLRecordSchema): + return bool(self.fields == other.fields and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.fields, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLRecordSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + if "fields" in _doc: + try: + fields = load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") ) - ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) + else: + fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1372,19 +3003,18 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `fields`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type=type, + fields=fields, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1401,13 +3031,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1418,7 +3048,7 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) + attrs = frozenset(["fields", "type"]) class File(Saveable): @@ -1508,7 +3138,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1572,51 +3201,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "File": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "File": - raise ValidationException("Not a File") + raise ValidationException("tried `File` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -1626,15 +3306,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "dirname" in _doc: @@ -1644,15 +3348,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dirname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dirname' field is not valid because:", - SourceLine(_doc, "dirname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dirname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dirname")))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + ) + ) else: dirname = None if "nameroot" in _doc: @@ -1662,15 +3390,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameroot") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameroot' field is not valid because:", - SourceLine(_doc, "nameroot", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameroot`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameroot")))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + ) + ) else: nameroot = None if "nameext" in _doc: @@ -1680,15 +3432,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameext") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameext' field is not valid because:", - SourceLine(_doc, "nameext", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameext`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameext")))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + ) + ) else: nameext = None if "checksum" in _doc: @@ -1698,15 +3474,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("checksum") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'checksum' field is not valid because:", - SourceLine(_doc, "checksum", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `checksum`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("checksum")))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + ) + ) else: checksum = None if "size" in _doc: @@ -1716,15 +3516,39 @@ def fromDoc( union_of_None_type_or_inttype, baseuri, loadingOptions, + lc=_doc.get("size") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'size' field is not valid because:", - SourceLine(_doc, "size", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("size")))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + ) + ) else: size = None if "secondaryFiles" in _doc: @@ -1734,33 +3558,81 @@ def fromDoc( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "contents" in _doc: @@ -1770,21 +3642,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("contents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'contents' field is not valid because:", - SourceLine(_doc, "contents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("contents")))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + ) + ) else: contents = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1798,10 +3698,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'File'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -1960,7 +3859,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1997,51 +3895,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Directory": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Directory": - raise ValidationException("Not a Directory") + raise ValidationException("tried `Directory` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -2051,15 +4000,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "listing" in _doc: @@ -2069,21 +4042,49 @@ def fromDoc( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) else: listing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2097,10 +4098,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Directory'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -2179,18 +4179,17 @@ class OutputSchema(SchemaBase): pass -class InputRecordField(RecordField): +class InputRecordField(CWLRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, inputBinding: Optional[Any] = None, label: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2199,25 +4198,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name self.doc = doc - self.type = type + self.name = name + self.type_ = type_ self.inputBinding = inputBinding self.label = label def __eq__(self, other: Any) -> bool: if isinstance(other, InputRecordField): return bool( - self.name == other.name - and self.doc == other.doc - and self.type == other.type + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ and self.inputBinding == other.inputBinding and self.label == other.label ) return False def __hash__(self) -> int: - return hash((self.name, self.doc, self.type, self.inputBinding, self.label)) + return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) @classmethod def fromDoc( @@ -2225,9 +4224,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2236,18 +4236,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2256,42 +4280,93 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: try: doc = load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -2299,15 +4374,39 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None if "label" in _doc: @@ -2317,21 +4416,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2339,20 +4466,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `doc`, `type`, `inputBinding`, `label`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, doc=doc, - type=type, + name=name, + type_=type_, inputBinding=inputBinding, label=label, extension_fields=extension_fields, @@ -2379,9 +4505,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -2403,20 +4529,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "doc", "type", "inputBinding", "label"]) + attrs = frozenset(["doc", "name", "type", "inputBinding", "label"]) -class InputRecordSchema(RecordSchema, InputSchema): +class InputRecordSchema(CWLRecordSchema, InputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2426,7 +4551,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.name = name @@ -2434,14 +4559,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.name)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -2449,9 +4574,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2460,18 +4586,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2490,32 +4640,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Record_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2523,21 +4724,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2551,13 +4780,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, name=name, extension_fields=extension_fields, @@ -2584,9 +4812,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2608,14 +4836,13 @@ class InputEnumSchema(EnumSchema, InputSchema): def __init__( self, symbols: Any, - type: Any, - label: Optional[Any] = None, + type_: Any, name: Optional[Any] = None, + label: Optional[Any] = None, inputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2624,25 +4851,27 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label - self.name = name self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, InputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label - and self.name == other.name and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.name, self.inputBinding)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.inputBinding) + ) @classmethod def fromDoc( @@ -2650,9 +4879,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2661,18 +4891,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2685,35 +4939,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Enum_symbolLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2721,15 +5029,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "inputBinding" in _doc: @@ -2739,21 +5071,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2761,21 +5121,20 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, - name=name, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -2800,9 +5159,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2824,20 +5183,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "name", "inputBinding"]) + attrs = frozenset(["name", "symbols", "type", "label", "inputBinding"]) -class InputArraySchema(ArraySchema, InputSchema): +class InputArraySchema(CWLArraySchema, InputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, inputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2847,7 +5205,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.inputBinding = inputBinding @@ -2855,14 +5213,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.inputBinding)) + return hash((self.items, self.type_, self.label, self.inputBinding)) @classmethod def fromDoc( @@ -2870,43 +5228,98 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_symbolLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2914,15 +5327,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "inputBinding" in _doc: @@ -2932,21 +5369,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2960,13 +5425,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, inputBinding=inputBinding, extension_fields=extension_fields, @@ -2986,12 +5450,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3016,17 +5479,16 @@ def save( attrs = frozenset(["items", "type", "label", "inputBinding"]) -class OutputRecordField(RecordField): +class OutputRecordField(CWLRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3035,23 +5497,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name self.doc = doc - self.type = type + self.name = name + self.type_ = type_ self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, OutputRecordField): return bool( - self.name == other.name - and self.doc == other.doc - and self.type == other.type + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.name, self.doc, self.type, self.outputBinding)) + return hash((self.doc, self.name, self.type_, self.outputBinding)) @classmethod def fromDoc( @@ -3059,9 +5521,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3070,18 +5533,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3090,42 +5577,93 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: try: doc = load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "outputBinding" in _doc: try: outputBinding = load_field( @@ -3133,21 +5671,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3155,20 +5721,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `doc`, `type`, `outputBinding`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, doc=doc, - type=type, + name=name, + type_=type_, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -3194,9 +5759,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( @@ -3214,19 +5779,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "doc", "type", "outputBinding"]) + attrs = frozenset(["doc", "name", "type", "outputBinding"]) -class OutputRecordSchema(RecordSchema, OutputSchema): +class OutputRecordSchema(CWLRecordSchema, OutputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3236,20 +5800,20 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label def __eq__(self, other: Any) -> bool: if isinstance(other, OutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label ) return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label)) + return hash((self.fields, self.type_, self.label)) @classmethod def fromDoc( @@ -3257,9 +5821,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3271,32 +5836,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Record_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3304,21 +5920,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3332,13 +5976,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -3360,9 +6003,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3384,13 +6027,13 @@ class OutputEnumSchema(EnumSchema, OutputSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3399,23 +6042,27 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, OutputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.outputBinding)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.outputBinding) + ) @classmethod def fromDoc( @@ -3423,43 +6070,149 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Enum_symbolLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3467,15 +6220,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "outputBinding" in _doc: @@ -3485,21 +6262,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3507,24 +6312,25 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `outputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -3538,22 +6344,25 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u if self.symbols is not None: - u = save_relative_uri(self.symbols, base_url, True, None, relative_uris) + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( self.outputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) @@ -3565,20 +6374,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "outputBinding"]) + attrs = frozenset(["name", "symbols", "type", "label", "outputBinding"]) -class OutputArraySchema(ArraySchema, OutputSchema): +class OutputArraySchema(CWLArraySchema, OutputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3588,7 +6396,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.outputBinding = outputBinding @@ -3596,14 +6404,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, OutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.outputBinding)) + return hash((self.items, self.type_, self.label, self.outputBinding)) @classmethod def fromDoc( @@ -3611,43 +6419,98 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_symbolLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3655,15 +6518,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "outputBinding" in _doc: @@ -3673,21 +6560,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3701,13 +6616,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, outputBinding=outputBinding, extension_fields=extension_fields, @@ -3727,12 +6641,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3768,11 +6681,10 @@ def __init__( format: Optional[Any] = None, inputBinding: Optional[Any] = None, default: Optional[Any] = None, - type: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3789,7 +6701,7 @@ def __init__( self.format = format self.inputBinding = inputBinding self.default = default - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, InputParameter): @@ -3802,7 +6714,7 @@ def __eq__(self, other: Any) -> bool: and self.format == other.format and self.inputBinding == other.inputBinding and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -3817,7 +6729,7 @@ def __hash__(self) -> int: self.format, self.inputBinding, self.default, - self.type, + self.type_, ) ) @@ -3827,9 +6739,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3838,18 +6751,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -3858,7 +6795,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -3868,15 +6805,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -3886,15 +6847,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -3904,15 +6889,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -3922,33 +6931,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "inputBinding" in _doc: @@ -3958,57 +7015,133 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None if "type" in _doc: try: - type = load_field( + type_ = load_field( _doc.get("type"), typedsl_union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) else: - type = None + type_ = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4022,10 +7155,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputParameter'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -4035,7 +7167,7 @@ def fromDoc( format=format, inputBinding=inputBinding, default=default, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -4092,9 +7224,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -4133,7 +7265,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4182,9 +7313,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -4193,18 +7325,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -4213,7 +7369,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -4223,15 +7379,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -4241,15 +7421,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -4259,15 +7463,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -4277,15 +7505,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "outputBinding" in _doc: @@ -4295,39 +7547,91 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4341,10 +7645,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputParameter'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -4467,7 +7770,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4496,16 +7798,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InlineJavascriptRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InlineJavascriptRequirement": - raise ValidationException("Not a InlineJavascriptRequirement") + raise ValidationException("tried `InlineJavascriptRequirement` but") if "expressionLib" in _doc: try: @@ -4514,21 +7819,49 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("expressionLib") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expressionLib' field is not valid because:", - SourceLine(_doc, "expressionLib", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expressionLib`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expressionLib")))) + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [e], + ) + ) else: expressionLib = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4542,12 +7875,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InlineJavascriptRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( expressionLib=expressionLib, extension_fields=extension_fields, @@ -4605,7 +7935,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4631,36 +7960,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SchemaDefRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SchemaDefRequirement": - raise ValidationException("Not a SchemaDefRequirement") + raise ValidationException("tried `SchemaDefRequirement` but") try: + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) + types = load_field( _doc.get("types"), array_of_union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader, baseuri, loadingOptions, + lc=_doc.get("types") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'types' field is not valid because:", - SourceLine(_doc, "types", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `types`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("types")))) + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4674,10 +8037,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SchemaDefRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( types=types, extension_fields=extension_fields, @@ -4729,7 +8091,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4757,47 +8118,106 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvironmentDef": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) + envName = load_field( _doc.get("envName"), strtype, baseuri, loadingOptions, + lc=_doc.get("envName") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envName' field is not valid because:", - SourceLine(_doc, "envName", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envName`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envName")))) + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [e], + ) + ) try: + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) + envValue = load_field( _doc.get("envValue"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("envValue") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envValue' field is not valid because:", - SourceLine(_doc, "envValue", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envValue`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envValue")))) + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4811,10 +8231,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvironmentDef'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envName=envName, envValue=envValue, @@ -4906,7 +8325,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4955,9 +8373,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -4969,15 +8388,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "position" in _doc: @@ -4987,15 +8430,39 @@ def fromDoc( union_of_None_type_or_inttype, baseuri, loadingOptions, + lc=_doc.get("position") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'position' field is not valid because:", - SourceLine(_doc, "position", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("position")))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + ) + ) else: position = None if "prefix" in _doc: @@ -5005,15 +8472,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("prefix") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'prefix' field is not valid because:", - SourceLine(_doc, "prefix", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `prefix`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("prefix")))) + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [e], + ) + ) else: prefix = None if "separate" in _doc: @@ -5023,15 +8514,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("separate") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'separate' field is not valid because:", - SourceLine(_doc, "separate", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `separate`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("separate")))) + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [e], + ) + ) else: separate = None if "itemSeparator" in _doc: @@ -5041,15 +8556,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("itemSeparator") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'itemSeparator' field is not valid because:", - SourceLine(_doc, "itemSeparator", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `itemSeparator`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("itemSeparator")))) + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [e], + ) + ) else: itemSeparator = None if "valueFrom" in _doc: @@ -5059,15 +8598,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None if "shellQuote" in _doc: @@ -5077,21 +8640,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("shellQuote") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'shellQuote' field is not valid because:", - SourceLine(_doc, "shellQuote", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `shellQuote`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("shellQuote")))) + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [e], + ) + ) else: shellQuote = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5105,10 +8696,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, position=position, @@ -5218,7 +8808,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5249,9 +8838,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5263,15 +8853,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("glob") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'glob' field is not valid because:", - SourceLine(_doc, "glob", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `glob`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("glob")))) + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [e], + ) + ) else: glob = None if "loadContents" in _doc: @@ -5281,15 +8895,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "outputEval" in _doc: @@ -5299,21 +8937,49 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outputEval") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputEval' field is not valid because:", - SourceLine(_doc, "outputEval", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputEval`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputEval")))) + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [e], + ) + ) else: outputEval = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5327,10 +8993,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandOutputBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( glob=glob, loadContents=loadContents, @@ -5385,14 +9050,13 @@ class CommandInputRecordField(InputRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, inputBinding: Optional[Any] = None, label: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5401,25 +9065,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name self.doc = doc - self.type = type + self.name = name + self.type_ = type_ self.inputBinding = inputBinding self.label = label def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputRecordField): return bool( - self.name == other.name - and self.doc == other.doc - and self.type == other.type + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ and self.inputBinding == other.inputBinding and self.label == other.label ) return False def __hash__(self) -> int: - return hash((self.name, self.doc, self.type, self.inputBinding, self.label)) + return hash((self.doc, self.name, self.type_, self.inputBinding, self.label)) @classmethod def fromDoc( @@ -5427,9 +9091,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5438,18 +9103,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -5458,42 +9147,93 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: try: doc = load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -5501,15 +9241,39 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None if "label" in _doc: @@ -5519,21 +9283,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5541,22 +9333,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `doc`, `type`, `inputBinding`, `label`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `inputBinding`, `label`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, doc=doc, - type=type, + name=name, + type_=type_, inputBinding=inputBinding, label=label, extension_fields=extension_fields, @@ -5583,9 +9372,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -5607,20 +9396,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "doc", "type", "inputBinding", "label"]) + attrs = frozenset(["doc", "name", "type", "inputBinding", "label"]) class CommandInputRecordSchema(InputRecordSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5630,7 +9418,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.name = name @@ -5638,14 +9426,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.name)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -5653,9 +9441,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5664,18 +9453,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -5694,32 +9507,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Record_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -5727,21 +9591,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5755,15 +9647,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, name=name, extension_fields=extension_fields, @@ -5790,9 +9679,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -5814,14 +9703,13 @@ class CommandInputEnumSchema(InputEnumSchema): def __init__( self, symbols: Any, - type: Any, - label: Optional[Any] = None, + type_: Any, name: Optional[Any] = None, + label: Optional[Any] = None, inputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5830,25 +9718,27 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label - self.name = name self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label - and self.name == other.name and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.name, self.inputBinding)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.inputBinding) + ) @classmethod def fromDoc( @@ -5856,9 +9746,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5867,18 +9758,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -5891,35 +9806,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Enum_symbolLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -5927,15 +9896,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "inputBinding" in _doc: @@ -5945,21 +9938,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5967,23 +9988,20 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `inputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, - name=name, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -6008,9 +10026,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6032,20 +10050,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "name", "inputBinding"]) + attrs = frozenset(["name", "symbols", "type", "label", "inputBinding"]) class CommandInputArraySchema(InputArraySchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, inputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6055,7 +10072,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.inputBinding = inputBinding @@ -6063,14 +10080,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.inputBinding == other.inputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.inputBinding)) + return hash((self.items, self.type_, self.label, self.inputBinding)) @classmethod def fromDoc( @@ -6078,43 +10095,98 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_symbolLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6122,15 +10194,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "inputBinding" in _doc: @@ -6140,21 +10236,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6168,15 +10292,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, inputBinding=inputBinding, extension_fields=extension_fields, @@ -6196,12 +10317,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6230,13 +10350,12 @@ class CommandOutputRecordField(OutputRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6245,23 +10364,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name self.doc = doc - self.type = type + self.name = name + self.type_ = type_ self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputRecordField): return bool( - self.name == other.name - and self.doc == other.doc - and self.type == other.type + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.name, self.doc, self.type, self.outputBinding)) + return hash((self.doc, self.name, self.type_, self.outputBinding)) @classmethod def fromDoc( @@ -6269,9 +10388,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6280,18 +10400,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6300,42 +10444,93 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: try: doc = load_field( _doc.get("doc"), - union_of_None_type_or_strtype, + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "outputBinding" in _doc: try: outputBinding = load_field( @@ -6343,21 +10538,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6365,22 +10588,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `doc`, `type`, `outputBinding`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`, `outputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, doc=doc, - type=type, + name=name, + type_=type_, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -6406,9 +10626,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( @@ -6426,20 +10646,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "doc", "type", "outputBinding"]) + attrs = frozenset(["doc", "name", "type", "outputBinding"]) class CommandOutputRecordSchema(OutputRecordSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6449,7 +10668,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.name = name @@ -6457,14 +10676,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.name)) + return hash((self.fields, self.type_, self.label, self.name)) @classmethod def fromDoc( @@ -6472,9 +10691,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6483,18 +10703,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6513,32 +10757,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Record_symbolLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6546,21 +10841,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6574,15 +10897,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, name=name, extension_fields=extension_fields, @@ -6609,9 +10929,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6633,13 +10953,13 @@ class CommandOutputEnumSchema(OutputEnumSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6648,23 +10968,27 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.outputBinding)) + return hash( + (self.name, self.symbols, self.type_, self.label, self.outputBinding) + ) @classmethod def fromDoc( @@ -6672,43 +10996,149 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Enum_symbolLoader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6716,15 +11146,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "outputBinding" in _doc: @@ -6734,21 +11188,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6756,26 +11238,25 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `outputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `outputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -6789,22 +11270,25 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u if self.symbols is not None: - u = save_relative_uri(self.symbols, base_url, True, None, relative_uris) + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + self.label, top=False, base_url=self.name, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( self.outputBinding, top=False, - base_url=base_url, + base_url=self.name, relative_uris=relative_uris, ) @@ -6816,20 +11300,19 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "outputBinding"]) + attrs = frozenset(["name", "symbols", "type", "label", "outputBinding"]) class CommandOutputArraySchema(OutputArraySchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, outputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6839,7 +11322,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.outputBinding = outputBinding @@ -6847,14 +11330,14 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.outputBinding == other.outputBinding ) return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.outputBinding)) + return hash((self.items, self.type_, self.label, self.outputBinding)) @classmethod def fromDoc( @@ -6862,43 +11345,98 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_symbolLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6906,15 +11444,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "outputBinding" in _doc: @@ -6924,21 +11486,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6952,15 +11542,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, outputBinding=outputBinding, extension_fields=extension_fields, @@ -6980,12 +11567,11 @@ def save( for ef in self.extension_fields: r[ef] = self.extension_fields[ef] if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7025,11 +11611,10 @@ def __init__( format: Optional[Any] = None, inputBinding: Optional[Any] = None, default: Optional[Any] = None, - type: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7046,7 +11631,7 @@ def __init__( self.format = format self.inputBinding = inputBinding self.default = default - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputParameter): @@ -7059,7 +11644,7 @@ def __eq__(self, other: Any) -> bool: and self.format == other.format and self.inputBinding == other.inputBinding and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -7074,7 +11659,7 @@ def __hash__(self) -> int: self.format, self.inputBinding, self.default, - self.type, + self.type_, ) ) @@ -7084,9 +11669,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7095,18 +11681,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -7115,7 +11725,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -7125,15 +11735,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -7143,15 +11777,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -7161,15 +11819,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -7179,33 +11861,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "inputBinding" in _doc: @@ -7215,57 +11945,133 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None if "type" in _doc: try: - type = load_field( + type_ = load_field( _doc.get("type"), typedsl_union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) else: - type = None + type_ = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7279,10 +12085,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandInputParameter'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -7292,7 +12097,7 @@ def fromDoc( format=format, inputBinding=inputBinding, default=default, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -7349,9 +12154,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -7391,11 +12196,10 @@ def __init__( doc: Optional[Any] = None, outputBinding: Optional[Any] = None, format: Optional[Any] = None, - type: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7411,7 +12215,7 @@ def __init__( self.id = id self.outputBinding = outputBinding self.format = format - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputParameter): @@ -7423,7 +12227,7 @@ def __eq__(self, other: Any) -> bool: and self.id == other.id and self.outputBinding == other.outputBinding and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -7437,7 +12241,7 @@ def __hash__(self) -> int: self.id, self.outputBinding, self.format, - self.type, + self.type_, ) ) @@ -7447,9 +12251,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7458,18 +12263,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -7478,7 +12307,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -7488,15 +12317,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -7506,15 +12359,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -7524,15 +12401,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -7542,15 +12443,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "outputBinding" in _doc: @@ -7560,57 +12485,133 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "type" in _doc: try: - type = load_field( + type_ = load_field( _doc.get("type"), typedsl_union_of_None_type_or_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) else: - type = None + type_ = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7624,12 +12625,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -7638,7 +12636,7 @@ def fromDoc( id=id, outputBinding=outputBinding, format=format, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -7691,9 +12689,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -7745,7 +12743,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7824,33 +12821,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "CommandLineTool": - raise ValidationException("Not a CommandLineTool") + raise ValidationException("tried `CommandLineTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -7863,35 +12887,89 @@ def fromDoc( if not __original_id_is_none: baseuri = id try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_CommandInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_CommandOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -7899,15 +12977,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -7917,15 +13019,39 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "label" in _doc: @@ -7935,15 +13061,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7953,33 +13103,81 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "baseCommand" in _doc: @@ -7989,15 +13187,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("baseCommand") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'baseCommand' field is not valid because:", - SourceLine(_doc, "baseCommand", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `baseCommand`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("baseCommand")))) + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [e], + ) + ) else: baseCommand = None if "arguments" in _doc: @@ -8007,15 +13229,39 @@ def fromDoc( union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("arguments") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'arguments' field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `arguments`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("arguments")))) + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [e], + ) + ) else: arguments = None if "stdin" in _doc: @@ -8025,15 +13271,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdin' field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdin")))) + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [e], + ) + ) else: stdin = None if "stderr" in _doc: @@ -8043,15 +13313,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stderr") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stderr' field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stderr`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stderr")))) + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [e], + ) + ) else: stderr = None if "stdout" in _doc: @@ -8061,15 +13355,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdout") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdout' field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdout`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdout")))) + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [e], + ) + ) else: stdout = None if "successCodes" in _doc: @@ -8079,15 +13397,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("successCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'successCodes' field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `successCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("successCodes")))) + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [e], + ) + ) else: successCodes = None if "temporaryFailCodes" in _doc: @@ -8097,15 +13439,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("temporaryFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'temporaryFailCodes' field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `temporaryFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("temporaryFailCodes")))) + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [e], + ) + ) else: temporaryFailCodes = None if "permanentFailCodes" in _doc: @@ -8115,21 +13481,49 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("permanentFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'permanentFailCodes' field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `permanentFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("permanentFailCodes")))) + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [e], + ) + ) else: permanentFailCodes = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8143,10 +13537,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, inputs=inputs, @@ -8341,7 +13734,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8390,16 +13782,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "DockerRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "DockerRequirement": - raise ValidationException("Not a DockerRequirement") + raise ValidationException("tried `DockerRequirement` but") if "dockerPull" in _doc: try: @@ -8408,15 +13803,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerPull") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerPull' field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerPull`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerPull")))) + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [e], + ) + ) else: dockerPull = None if "dockerLoad" in _doc: @@ -8426,15 +13845,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerLoad") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerLoad' field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerLoad`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerLoad")))) + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [e], + ) + ) else: dockerLoad = None if "dockerFile" in _doc: @@ -8444,15 +13887,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerFile") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerFile' field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerFile`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerFile")))) + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [e], + ) + ) else: dockerFile = None if "dockerImport" in _doc: @@ -8462,15 +13929,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImport") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImport' field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImport`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImport")))) + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [e], + ) + ) else: dockerImport = None if "dockerImageId" in _doc: @@ -8480,15 +13971,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImageId") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImageId' field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImageId`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImageId")))) + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [e], + ) + ) else: dockerImageId = None if "dockerOutputDirectory" in _doc: @@ -8498,21 +14013,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerOutputDirectory") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerOutputDirectory' field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerOutputDirectory`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerOutputDirectory")))) + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [e], + ) + ) else: dockerOutputDirectory = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8526,10 +14069,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'DockerRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( dockerPull=dockerPull, dockerLoad=dockerLoad, @@ -8632,7 +14174,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8658,36 +14199,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwareRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SoftwareRequirement": - raise ValidationException("Not a SoftwareRequirement") + raise ValidationException("tried `SoftwareRequirement` but") try: + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) + packages = load_field( _doc.get("packages"), idmap_packages_array_of_SoftwarePackageLoader, baseuri, loadingOptions, + lc=_doc.get("packages") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'packages' field is not valid because:", - SourceLine(_doc, "packages", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `packages`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("packages")))) + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8701,10 +14276,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwareRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( packages=packages, extension_fields=extension_fields, @@ -8750,7 +14324,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8781,28 +14354,56 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwarePackage": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) + package = load_field( _doc.get("package"), strtype, baseuri, loadingOptions, + lc=_doc.get("package") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'package' field is not valid because:", - SourceLine(_doc, "package", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `package`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("package")))) + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [e], + ) + ) if "version" in _doc: try: version = load_field( @@ -8810,39 +14411,91 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("version") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'version' field is not valid because:", - SourceLine(_doc, "version", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `version`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("version")))) + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [e], + ) + ) else: version = None if "specs" in _doc: try: specs = load_field( _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None, + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, baseuri, loadingOptions, + lc=_doc.get("specs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'specs' field is not valid because:", - SourceLine(_doc, "specs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `specs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("specs")))) + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [e], + ) + ) else: specs = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8856,10 +14509,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwarePackage'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( package=package, version=version, @@ -8920,7 +14572,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8951,9 +14602,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Dirent": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -8965,32 +14617,83 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entryname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entryname' field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entryname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entryname")))) + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [e], + ) + ) else: entryname = None try: + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) + entry = load_field( _doc.get("entry"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entry") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entry' field is not valid because:", - SourceLine(_doc, "entry", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entry`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entry")))) + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [e], + ) + ) if "writable" in _doc: try: writable = load_field( @@ -8998,21 +14701,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("writable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'writable' field is not valid because:", - SourceLine(_doc, "writable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `writable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("writable")))) + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [e], + ) + ) else: writable = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9026,10 +14757,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Dirent'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( entryname=entryname, entry=entry, @@ -9088,7 +14818,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9114,36 +14843,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InitialWorkDirRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InitialWorkDirRequirement": - raise ValidationException("Not a InitialWorkDirRequirement") + raise ValidationException("tried `InitialWorkDirRequirement` but") try: + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) + listing = load_field( _doc.get("listing"), union_of_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9157,12 +14920,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InitialWorkDirRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( listing=listing, extension_fields=extension_fields, @@ -9212,7 +14972,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9238,36 +14997,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvVarRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "EnvVarRequirement": - raise ValidationException("Not a EnvVarRequirement") + raise ValidationException("tried `EnvVarRequirement` but") try: + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) + envDef = load_field( _doc.get("envDef"), idmap_envDef_array_of_EnvironmentDefLoader, baseuri, loadingOptions, + lc=_doc.get("envDef") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envDef' field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envDef`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envDef")))) + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9281,10 +15074,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvVarRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envDef=envDef, extension_fields=extension_fields, @@ -9338,7 +15130,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9363,21 +15154,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ShellCommandRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ShellCommandRequirement": - raise ValidationException("Not a ShellCommandRequirement") + raise ValidationException("tried `ShellCommandRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9389,12 +15187,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ShellCommandRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -9464,7 +15259,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9519,16 +15313,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ResourceRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ResourceRequirement": - raise ValidationException("Not a ResourceRequirement") + raise ValidationException("tried `ResourceRequirement` but") if "coresMin" in _doc: try: @@ -9537,15 +15334,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMin' field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMin")))) + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [e], + ) + ) else: coresMin = None if "coresMax" in _doc: @@ -9555,15 +15376,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMax' field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMax")))) + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [e], + ) + ) else: coresMax = None if "ramMin" in _doc: @@ -9573,15 +15418,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMin' field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMin")))) + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [e], + ) + ) else: ramMin = None if "ramMax" in _doc: @@ -9591,15 +15460,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMax' field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMax")))) + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [e], + ) + ) else: ramMax = None if "tmpdirMin" in _doc: @@ -9609,15 +15502,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMin' field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMin")))) + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [e], + ) + ) else: tmpdirMin = None if "tmpdirMax" in _doc: @@ -9627,15 +15544,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMax' field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMax")))) + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [e], + ) + ) else: tmpdirMax = None if "outdirMin" in _doc: @@ -9645,15 +15586,39 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMin' field is not valid because:", - SourceLine(_doc, "outdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMin")))) + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [e], + ) + ) else: outdirMin = None if "outdirMax" in _doc: @@ -9663,21 +15628,49 @@ def fromDoc( union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMax' field is not valid because:", - SourceLine(_doc, "outdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMax")))) + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [e], + ) + ) else: outdirMax = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9691,10 +15684,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ResourceRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( coresMin=coresMin, coresMax=coresMax, @@ -9800,11 +15792,10 @@ def __init__( doc: Optional[Any] = None, outputBinding: Optional[Any] = None, format: Optional[Any] = None, - type: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9820,7 +15811,7 @@ def __init__( self.id = id self.outputBinding = outputBinding self.format = format - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, ExpressionToolOutputParameter): @@ -9832,7 +15823,7 @@ def __eq__(self, other: Any) -> bool: and self.id == other.id and self.outputBinding == other.outputBinding and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -9846,7 +15837,7 @@ def __hash__(self) -> int: self.id, self.outputBinding, self.format, - self.type, + self.type_, ) ) @@ -9856,9 +15847,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionToolOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -9867,18 +15859,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -9887,7 +15903,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -9897,15 +15913,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -9915,15 +15955,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -9933,15 +15997,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -9951,15 +16039,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "outputBinding" in _doc: @@ -9969,57 +16081,133 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "type" in _doc: try: - type = load_field( + type_ = load_field( _doc.get("type"), typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) else: - type = None + type_ = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10033,12 +16221,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ExpressionToolOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -10047,7 +16232,7 @@ def fromDoc( id=id, outputBinding=outputBinding, format=format, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -10100,9 +16285,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -10147,7 +16332,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10205,33 +16389,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ExpressionTool": - raise ValidationException("Not a ExpressionTool") + raise ValidationException("tried `ExpressionTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -10244,35 +16455,89 @@ def fromDoc( if not __original_id_is_none: baseuri = id try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_InputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_ExpressionToolOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -10280,15 +16545,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -10298,15 +16587,39 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "label" in _doc: @@ -10316,15 +16629,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -10334,54 +16671,133 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None try: + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) + expression = load_field( _doc.get("expression"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("expression") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expression' field is not valid because:", - SourceLine(_doc, "expression", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expression`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expression")))) + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10395,10 +16811,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ExpressionTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, inputs=inputs, @@ -10512,11 +16927,10 @@ def __init__( format: Optional[Any] = None, outputSource: Optional[Any] = None, linkMerge: Optional[Any] = None, - type: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10534,7 +16948,7 @@ def __init__( self.format = format self.outputSource = outputSource self.linkMerge = linkMerge - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, WorkflowOutputParameter): @@ -10548,7 +16962,7 @@ def __eq__(self, other: Any) -> bool: and self.format == other.format and self.outputSource == other.outputSource and self.linkMerge == other.linkMerge - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -10564,7 +16978,7 @@ def __hash__(self) -> int: self.format, self.outputSource, self.linkMerge, - self.type, + self.type_, ) ) @@ -10574,9 +16988,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -10585,18 +17000,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -10605,7 +17044,7 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "label" in _doc: @@ -10615,15 +17054,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -10633,15 +17096,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -10651,15 +17138,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -10669,15 +17180,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "outputBinding" in _doc: @@ -10687,51 +17222,123 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "outputSource" in _doc: try: outputSource = load_field( _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, baseuri, loadingOptions, + lc=_doc.get("outputSource") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputSource' field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputSource`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputSource")))) + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [e], + ) + ) else: outputSource = None if "linkMerge" in _doc: @@ -10741,39 +17348,91 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None if "type" in _doc: try: - type = load_field( + type_ = load_field( _doc.get("type"), typedsl_union_of_None_type_or_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) else: - type = None + type_ = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10787,12 +17446,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'WorkflowOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -10803,7 +17459,7 @@ def fromDoc( format=format, outputSource=outputSource, linkMerge=linkMerge, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -10863,9 +17519,9 @@ def save( r["linkMerge"] = save( self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -10950,7 +17606,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10987,9 +17642,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepInput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -10998,18 +17654,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11018,25 +17698,49 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id if "source" in _doc: try: source = load_field( _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, baseuri, loadingOptions, + lc=_doc.get("source") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'source' field is not valid because:", - SourceLine(_doc, "source", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("source")))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + ) + ) else: source = None if "linkMerge" in _doc: @@ -11046,33 +17750,81 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None if "valueFrom" in _doc: @@ -11082,21 +17834,49 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11110,10 +17890,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepInput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( source=source, linkMerge=linkMerge, @@ -11182,7 +17961,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11207,9 +17985,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepOutput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11218,18 +17997,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11238,13 +18041,17 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11256,10 +18063,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepOutput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, extension_fields=extension_fields, @@ -11369,7 +18175,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11427,9 +18232,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStep": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11438,18 +18244,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11458,39 +18288,93 @@ def fromDoc( if docRoot is not None: id = docRoot else: - raise ValidationException("Missing id") + _errors__.append(ValidationException("missing id")) if not __original_id_is_none: baseuri = id try: + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) + in_ = load_field( _doc.get("in"), idmap_in__array_of_WorkflowStepInputLoader, baseuri, loadingOptions, + lc=_doc.get("in") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'in' field is not valid because:", - SourceLine(_doc, "in", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("in")))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + ) + ) try: + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) + out = load_field( _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None, + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("out") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'out' field is not valid because:", - SourceLine(_doc, "out", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `out`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("out")))) + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -11498,15 +18382,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -11516,15 +18424,39 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "label" in _doc: @@ -11534,15 +18466,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -11552,72 +18508,175 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) + run = load_field( _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None, + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("run") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'run' field is not valid because:", - SourceLine(_doc, "run", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `run`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("run")))) + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [e], + ) + ) if "scatter" in _doc: try: scatter = load_field( _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, baseuri, loadingOptions, + lc=_doc.get("scatter") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatter' field is not valid because:", - SourceLine(_doc, "scatter", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatter`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatter")))) + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [e], + ) + ) else: scatter = None if "scatterMethod" in _doc: try: scatterMethod = load_field( _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None, + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("scatterMethod") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatterMethod' field is not valid because:", - SourceLine(_doc, "scatterMethod", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatterMethod`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatterMethod")))) + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [e], + ) + ) else: scatterMethod = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11631,10 +18690,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStep'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, in_=in_, @@ -11792,7 +18850,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11850,33 +18907,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Workflow": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Workflow": - raise ValidationException("Not a Workflow") + raise ValidationException("tried `Workflow` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11889,35 +18973,89 @@ def fromDoc( if not __original_id_is_none: baseuri = id try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_InputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_WorkflowOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -11925,15 +19063,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -11943,15 +19105,39 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "label" in _doc: @@ -11961,15 +19147,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -11979,54 +19189,133 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None try: + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) + steps = load_field( _doc.get("steps"), idmap_steps_union_of_array_of_WorkflowStepLoader, baseuri, loadingOptions, + lc=_doc.get("steps") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'steps' field is not valid because:", - SourceLine(_doc, "steps", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `steps`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("steps")))) + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12040,10 +19329,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Workflow'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, inputs=inputs, @@ -12147,7 +19435,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12172,21 +19459,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SubworkflowFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SubworkflowFeatureRequirement": - raise ValidationException("Not a SubworkflowFeatureRequirement") + raise ValidationException("tried `SubworkflowFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12198,12 +19492,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'SubworkflowFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -12247,7 +19538,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12272,21 +19562,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ScatterFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ScatterFeatureRequirement": - raise ValidationException("Not a ScatterFeatureRequirement") + raise ValidationException("tried `ScatterFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12298,12 +19595,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ScatterFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -12347,7 +19641,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12372,21 +19665,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "MultipleInputFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "MultipleInputFeatureRequirement": - raise ValidationException("Not a MultipleInputFeatureRequirement") + raise ValidationException("tried `MultipleInputFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12398,12 +19698,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'MultipleInputFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -12447,7 +19744,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12472,21 +19768,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "StepInputExpressionRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "StepInputExpressionRequirement": - raise ValidationException("Not a StepInputExpressionRequirement") + raise ValidationException("tried `StepInputExpressionRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12498,12 +19801,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'StepInputExpressionRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -12538,6 +19838,11 @@ def save( _vocab = { "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", + "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", + "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", + "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", + "CWLRecordField": "https://w3id.org/cwl/cwl#CWLRecordField", + "CWLRecordSchema": "https://w3id.org/cwl/cwl#CWLRecordSchema", "CWLType": "https://w3id.org/cwl/cwl#CWLType", "CWLVersion": "https://w3id.org/cwl/cwl#CWLVersion", "CommandInputArraySchema": "https://w3id.org/cwl/cwl#CommandInputArraySchema", @@ -12556,6 +19861,7 @@ def save( "Directory": "https://w3id.org/cwl/cwl#Directory", "Dirent": "https://w3id.org/cwl/cwl#Dirent", "DockerRequirement": "https://w3id.org/cwl/cwl#DockerRequirement", + "Documented": "https://w3id.org/cwl/salad#Documented", "EnumSchema": "https://w3id.org/cwl/salad#EnumSchema", "EnvVarRequirement": "https://w3id.org/cwl/cwl#EnvVarRequirement", "EnvironmentDef": "https://w3id.org/cwl/cwl#EnvironmentDef", @@ -12574,6 +19880,7 @@ def save( "InputRecordSchema": "https://w3id.org/cwl/cwl#InputRecordSchema", "InputSchema": "https://w3id.org/cwl/cwl#InputSchema", "LinkMergeMethod": "https://w3id.org/cwl/cwl#LinkMergeMethod", + "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", "OutputArraySchema": "https://w3id.org/cwl/cwl#OutputArraySchema", "OutputBinding": "https://w3id.org/cwl/cwl#OutputBinding", @@ -12599,6 +19906,7 @@ def save( "SoftwareRequirement": "https://w3id.org/cwl/cwl#SoftwareRequirement", "StepInputExpressionRequirement": "https://w3id.org/cwl/cwl#StepInputExpressionRequirement", "SubworkflowFeatureRequirement": "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement", + "UnionSchema": "https://w3id.org/cwl/salad#UnionSchema", "Workflow": "https://w3id.org/cwl/cwl#Workflow", "WorkflowOutputParameter": "https://w3id.org/cwl/cwl#WorkflowOutputParameter", "WorkflowStep": "https://w3id.org/cwl/cwl#WorkflowStep", @@ -12623,6 +19931,7 @@ def save( "float": "http://www.w3.org/2001/XMLSchema#float", "int": "http://www.w3.org/2001/XMLSchema#int", "long": "http://www.w3.org/2001/XMLSchema#long", + "map": "https://w3id.org/cwl/salad#map", "merge_flattened": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened", "merge_nested": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested", "nested_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct", @@ -12631,12 +19940,18 @@ def save( "stderr": "https://w3id.org/cwl/cwl#stderr", "stdout": "https://w3id.org/cwl/cwl#stdout", "string": "http://www.w3.org/2001/XMLSchema#string", + "union": "https://w3id.org/cwl/salad#union", "v1.0": "https://w3id.org/cwl/cwl#v1.0", "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", } _rvocab = { "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", + "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", + "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", + "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", + "https://w3id.org/cwl/cwl#CWLRecordField": "CWLRecordField", + "https://w3id.org/cwl/cwl#CWLRecordSchema": "CWLRecordSchema", "https://w3id.org/cwl/cwl#CWLType": "CWLType", "https://w3id.org/cwl/cwl#CWLVersion": "CWLVersion", "https://w3id.org/cwl/cwl#CommandInputArraySchema": "CommandInputArraySchema", @@ -12655,6 +19970,7 @@ def save( "https://w3id.org/cwl/cwl#Directory": "Directory", "https://w3id.org/cwl/cwl#Dirent": "Dirent", "https://w3id.org/cwl/cwl#DockerRequirement": "DockerRequirement", + "https://w3id.org/cwl/salad#Documented": "Documented", "https://w3id.org/cwl/salad#EnumSchema": "EnumSchema", "https://w3id.org/cwl/cwl#EnvVarRequirement": "EnvVarRequirement", "https://w3id.org/cwl/cwl#EnvironmentDef": "EnvironmentDef", @@ -12673,6 +19989,7 @@ def save( "https://w3id.org/cwl/cwl#InputRecordSchema": "InputRecordSchema", "https://w3id.org/cwl/cwl#InputSchema": "InputSchema", "https://w3id.org/cwl/cwl#LinkMergeMethod": "LinkMergeMethod", + "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", "https://w3id.org/cwl/cwl#OutputArraySchema": "OutputArraySchema", "https://w3id.org/cwl/cwl#OutputBinding": "OutputBinding", @@ -12698,6 +20015,7 @@ def save( "https://w3id.org/cwl/cwl#SoftwareRequirement": "SoftwareRequirement", "https://w3id.org/cwl/cwl#StepInputExpressionRequirement": "StepInputExpressionRequirement", "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement": "SubworkflowFeatureRequirement", + "https://w3id.org/cwl/salad#UnionSchema": "UnionSchema", "https://w3id.org/cwl/cwl#Workflow": "Workflow", "https://w3id.org/cwl/cwl#WorkflowOutputParameter": "WorkflowOutputParameter", "https://w3id.org/cwl/cwl#WorkflowStep": "WorkflowStep", @@ -12722,6 +20040,7 @@ def save( "http://www.w3.org/2001/XMLSchema#float": "float", "http://www.w3.org/2001/XMLSchema#int": "int", "http://www.w3.org/2001/XMLSchema#long": "long", + "https://w3id.org/cwl/salad#map": "map", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened": "merge_flattened", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested": "merge_nested", "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct": "nested_crossproduct", @@ -12730,6 +20049,7 @@ def save( "https://w3id.org/cwl/cwl#stderr": "stderr", "https://w3id.org/cwl/cwl#stdout": "stdout", "http://www.w3.org/2001/XMLSchema#string": "string", + "https://w3id.org/cwl/salad#union": "union", "https://w3id.org/cwl/cwl#v1.0": "v1.0", "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", } @@ -12753,8 +20073,9 @@ def save( "PrimitiveType", ) """ -Salad data types are based on Avro schema declarations. Refer to the -[Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for +Names of salad data types (based on Avro schema declarations). + +Refer to the [Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for detailed information. null: no value @@ -12769,10 +20090,50 @@ def save( """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField) -RecordSchemaLoader = _RecordLoader(RecordSchema) -EnumSchemaLoader = _RecordLoader(EnumSchema) -ArraySchemaLoader = _RecordLoader(ArraySchema) +RecordFieldLoader = _RecordLoader(RecordField, None, None) +RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) +EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) +ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) +MapSchemaLoader = _RecordLoader(MapSchema, None, None) +UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) +CWLTypeLoader = _EnumLoader( + ( + "null", + "boolean", + "int", + "long", + "float", + "double", + "string", + "File", + "Directory", + ), + "CWLType", +) +""" +Extends primitive types with the concept of a file and directory as a builtin type. +File: A File object +Directory: A Directory object +""" +CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) +CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) +CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) +FileLoader = _RecordLoader(File, None, None) +DirectoryLoader = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) +) +array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( + union_of_None_type_or_CWLObjectTypeLoader +) +map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( + union_of_None_type_or_CWLObjectTypeLoader, "CWLInputFile", "@list", True +) +CWLInputFileLoader = map_of_union_of_None_type_or_CWLObjectTypeLoader CWLVersionLoader = _EnumLoader( ( "draft-2", @@ -12793,53 +20154,34 @@ def save( """ Version symbols for published CWL document versions. """ -CWLTypeLoader = _EnumLoader( - ( - "null", - "boolean", - "int", - "long", - "float", - "double", - "string", - "File", - "Directory", - ), - "CWLType", -) -""" -Extends primitive types with the concept of a file and directory as a builtin type. -File: A File object -Directory: A Directory object -""" -FileLoader = _RecordLoader(File) -DirectoryLoader = _RecordLoader(Directory) ExpressionLoader = _ExpressionLoader(str) -InputRecordFieldLoader = _RecordLoader(InputRecordField) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema) -InputArraySchemaLoader = _RecordLoader(InputArraySchema) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema) -InputParameterLoader = _RecordLoader(InputParameter) -OutputParameterLoader = _RecordLoader(OutputParameter) -InlineJavascriptRequirementLoader = _RecordLoader(InlineJavascriptRequirement) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter) +InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) +InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) +InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) +InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) +OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) +OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) +OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) +OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) +InputParameterLoader = _RecordLoader(InputParameter, None, None) +OutputParameterLoader = _RecordLoader(OutputParameter, None, None) +InlineJavascriptRequirementLoader = _RecordLoader( + InlineJavascriptRequirement, None, None +) +SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) +EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) +CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) +CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) +CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) +CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) +CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) +CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) +CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) +CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) +CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) +CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) +CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) +CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) stdoutLoader = _EnumLoader(("stdout",), "stdout") """ Only valid as a `type` for a `CommandLineTool` output with no @@ -12928,17 +20270,19 @@ def save( stderr: random_stderr_filenameABCDEFG ``` """ -CommandLineToolLoader = _RecordLoader(CommandLineTool) -DockerRequirementLoader = _RecordLoader(DockerRequirement) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage) -DirentLoader = _RecordLoader(Dirent) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement) -ExpressionToolOutputParameterLoader = _RecordLoader(ExpressionToolOutputParameter) -ExpressionToolLoader = _RecordLoader(ExpressionTool) +CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) +DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) +SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) +SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) +DirentLoader = _RecordLoader(Dirent, None, None) +InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) +EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) +ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) +ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) +ExpressionToolOutputParameterLoader = _RecordLoader( + ExpressionToolOutputParameter, None, None +) +ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) LinkMergeMethodLoader = _EnumLoader( ( "merge_nested", @@ -12949,9 +20293,9 @@ def save( """ The input link merge method, described in [WorkflowStepInput](#WorkflowStepInput). """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput) +WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) +WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) +WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) ScatterMethodLoader = _EnumLoader( ( "dotproduct", @@ -12963,43 +20307,55 @@ def save( """ The scatter method, as described in [workflow step scatter](#WorkflowStep). """ -WorkflowStepLoader = _RecordLoader(WorkflowStep) -WorkflowLoader = _RecordLoader(Workflow) -SubworkflowFeatureRequirementLoader = _RecordLoader(SubworkflowFeatureRequirement) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement) -MultipleInputFeatureRequirementLoader = _RecordLoader(MultipleInputFeatureRequirement) -StepInputExpressionRequirementLoader = _RecordLoader(StepInputExpressionRequirement) -uri_strtype_True_False_None = _URILoader(strtype, True, False, None) -union_of_None_type_or_strtype = _UnionLoader( +WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) +WorkflowLoader = _RecordLoader(Workflow, None, None) +SubworkflowFeatureRequirementLoader = _RecordLoader( + SubworkflowFeatureRequirement, None, None +) +ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) +MultipleInputFeatureRequirementLoader = _RecordLoader( + MultipleInputFeatureRequirement, None, None +) +StepInputExpressionRequirementLoader = _RecordLoader( + StepInputExpressionRequirement, None, None +) +array_of_strtype = _ArrayLoader(strtype) +union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( ( None_type, strtype, + array_of_strtype, ) ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _ArrayLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, - array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, + array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) @@ -13013,18 +20369,85 @@ def save( idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_RecordFieldLoader, "name", "type" ) -Record_symbolLoader = _EnumLoader(("record",), "Record_symbol") -typedsl_Record_symbolLoader_2 = _TypeDSLLoader(Record_symbolLoader, 2, "v1.1") -array_of_strtype = _ArrayLoader(strtype) -uri_array_of_strtype_True_False_None = _URILoader(array_of_strtype, True, False, None) -Enum_symbolLoader = _EnumLoader(("enum",), "Enum_symbol") -typedsl_Enum_symbolLoader_2 = _TypeDSLLoader(Enum_symbolLoader, 2, "v1.1") -Array_symbolLoader = _EnumLoader(("array",), "Array_symbol") -typedsl_Array_symbolLoader_2 = _TypeDSLLoader(Array_symbolLoader, 2, "v1.1") +Record_nameLoader = _EnumLoader(("record",), "Record_name") +typedsl_Record_nameLoader_2 = _TypeDSLLoader(Record_nameLoader, 2, "v1.1") +union_of_None_type_or_strtype = _UnionLoader( + ( + None_type, + strtype, + ) +) +uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( + union_of_None_type_or_strtype, True, False, None, None +) +uri_array_of_strtype_True_False_None_None = _URILoader( + array_of_strtype, True, False, None, None +) +Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") +typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, + False, + True, + 2, + None, +) +Array_nameLoader = _EnumLoader(("array",), "Array_name") +typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") +Map_nameLoader = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") +Union_nameLoader = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + ) +) +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype +) +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + ) +) +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + 2, + "v1.1", +) +array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) +union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( + ( + None_type, + array_of_CWLRecordFieldLoader, + ) +) +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( + union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" +) File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None = _URILoader(File_classLoader, False, True, None) -uri_union_of_None_type_or_strtype_False_False_None = _URILoader( - union_of_None_type_or_strtype, False, False, None +uri_File_classLoader_False_True_None_None = _URILoader( + File_classLoader, False, True, None, None +) +uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( + union_of_None_type_or_strtype, False, False, None, None ) union_of_None_type_or_inttype = _UnionLoader( ( @@ -13047,12 +20470,12 @@ def save( array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -uri_union_of_None_type_or_strtype_True_False_None = _URILoader( - union_of_None_type_or_strtype, True, False, None +uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( + union_of_None_type_or_strtype, True, False, None, True ) Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None = _URILoader( - Directory_classLoader, False, True, None +uri_Directory_classLoader_False_True_None_None = _URILoader( + Directory_classLoader, False, True, None, None ) union_of_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -13077,13 +20500,6 @@ def save( booltype, ) ) -union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( - ( - None_type, - strtype, - array_of_strtype, - ) -) union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -13127,6 +20543,13 @@ def save( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" ) +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -13170,6 +20593,13 @@ def save( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" ) +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( ( None_type, @@ -13178,19 +20608,12 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, -) -union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type = _UnionLoader( - ( - None_type, - FileLoader, - DirectoryLoader, - Any_type, - ) + True, ) union_of_None_type_or_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -13215,8 +20638,8 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None = _URILoader( - union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( + union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) array_of_InputParameterLoader = _ArrayLoader(InputParameterLoader) idmap_inputs_array_of_InputParameterLoader = _IdMapLoader( @@ -13293,14 +20716,14 @@ def save( CWLVersionLoader, ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( + union_of_None_type_or_CWLVersionLoader, False, True, None, None ) InlineJavascriptRequirement_classLoader = _EnumLoader( ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" ) -uri_InlineJavascriptRequirement_classLoader_False_True_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None +uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( + InlineJavascriptRequirement_classLoader, False, True, None, None ) union_of_None_type_or_array_of_strtype = _UnionLoader( ( @@ -13311,8 +20734,8 @@ def save( SchemaDefRequirement_classLoader = _EnumLoader( ("SchemaDefRequirement",), "SchemaDefRequirement_class" ) -uri_SchemaDefRequirement_classLoader_False_True_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None +uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( + SchemaDefRequirement_classLoader, False, True, None, None ) union_of_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader = ( _UnionLoader( @@ -13373,6 +20796,13 @@ def save( union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) ) +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -13412,6 +20842,13 @@ def save( union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) ) +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_None_type_or_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( ( None_type, @@ -13447,8 +20884,8 @@ def save( "v1.1", ) CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None = _URILoader( - CommandLineTool_classLoader, False, True, None +uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( + CommandLineTool_classLoader, False, True, None, None ) array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( @@ -13484,27 +20921,27 @@ def save( DockerRequirement_classLoader = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None = _URILoader( - DockerRequirement_classLoader, False, True, None +uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( + DockerRequirement_classLoader, False, True, None, None ) SoftwareRequirement_classLoader = _EnumLoader( ("SoftwareRequirement",), "SoftwareRequirement_class" ) -uri_SoftwareRequirement_classLoader_False_True_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None +uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( + SoftwareRequirement_classLoader, False, True, None, None ) array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( array_of_SoftwarePackageLoader, "package", "specs" ) -uri_union_of_None_type_or_array_of_strtype_False_False_None = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None +uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( + union_of_None_type_or_array_of_strtype, False, False, None, True ) InitialWorkDirRequirement_classLoader = _EnumLoader( ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" ) -uri_InitialWorkDirRequirement_classLoader_False_True_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None +uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( + InitialWorkDirRequirement_classLoader, False, True, None, None ) union_of_FileLoader_or_DirectoryLoader_or_DirentLoader_or_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -13528,8 +20965,8 @@ def save( EnvVarRequirement_classLoader = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None +uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( + EnvVarRequirement_classLoader, False, True, None, None ) array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( @@ -13538,14 +20975,14 @@ def save( ShellCommandRequirement_classLoader = _EnumLoader( ("ShellCommandRequirement",), "ShellCommandRequirement_class" ) -uri_ShellCommandRequirement_classLoader_False_True_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None +uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( + ShellCommandRequirement_classLoader, False, True, None, None ) ResourceRequirement_classLoader = _EnumLoader( ("ResourceRequirement",), "ResourceRequirement_class" ) -uri_ResourceRequirement_classLoader_False_True_None = _URILoader( - ResourceRequirement_classLoader, False, True, None +uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( + ResourceRequirement_classLoader, False, True, None, None ) union_of_None_type_or_inttype_or_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -13572,8 +21009,8 @@ def save( "v1.1", ) ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None = _URILoader( - ExpressionTool_classLoader, False, True, None +uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( + ExpressionTool_classLoader, False, True, None, None ) array_of_ExpressionToolOutputParameterLoader = _ArrayLoader( ExpressionToolOutputParameterLoader @@ -13581,8 +21018,8 @@ def save( idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( array_of_ExpressionToolOutputParameterLoader, "id", "type" ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None ) union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( ( @@ -13590,8 +21027,8 @@ def save( LinkMergeMethodLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None ) array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( @@ -13609,13 +21046,12 @@ def save( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) ) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None = ( - _URILoader( - union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, - True, - False, - None, - ) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( + union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, + True, + False, + None, + None, ) array_of_Any_type = _ArrayLoader(Any_type) union_of_None_type_or_array_of_Any_type = _UnionLoader( @@ -13637,14 +21073,15 @@ def save( ) ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None = _URILoader( +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None = _URILoader( union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, False, False, None, + None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None ) union_of_None_type_or_ScatterMethodLoader = _UnionLoader( ( @@ -13652,12 +21089,12 @@ def save( ScatterMethodLoader, ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( + union_of_None_type_or_ScatterMethodLoader, False, True, None, None ) Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None = _URILoader( - Workflow_classLoader, False, True, None +uri_Workflow_classLoader_False_True_None_None = _URILoader( + Workflow_classLoader, False, True, None, None ) array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( @@ -13671,26 +21108,26 @@ def save( SubworkflowFeatureRequirement_classLoader = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( + SubworkflowFeatureRequirement_classLoader, False, True, None, None ) ScatterFeatureRequirement_classLoader = _EnumLoader( ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" ) -uri_ScatterFeatureRequirement_classLoader_False_True_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None +uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( + ScatterFeatureRequirement_classLoader, False, True, None, None ) MultipleInputFeatureRequirement_classLoader = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( + MultipleInputFeatureRequirement_classLoader, False, True, None, None ) StepInputExpressionRequirement_classLoader = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None +uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( + StepInputExpressionRequirement_classLoader, False, True, None, None ) union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader = _UnionLoader( ( @@ -13713,6 +21150,19 @@ def save( ) ) +CWLObjectTypeLoader.add_loaders( + ( + booltype, + inttype, + floattype, + strtype, + FileLoader, + DirectoryLoader, + array_of_union_of_None_type_or_CWLObjectTypeLoader, + map_of_union_of_None_type_or_CWLObjectTypeLoader, + ) +) + def load_document( doc: Any, diff --git a/cwl_utils/parser/cwl_v1_0_utils.py b/cwl_utils/parser/cwl_v1_0_utils.py index 31221a9a..fb92ab59 100644 --- a/cwl_utils/parser/cwl_v1_0_utils.py +++ b/cwl_utils/parser/cwl_v1_0_utils.py @@ -1,12 +1,26 @@ # SPDX-License-Identifier: Apache-2.0 import hashlib import logging +import os from collections import namedtuple -from typing import IO, Any, Dict, List, MutableSequence, Optional, Tuple, Union, cast +from io import StringIO +from typing import ( + Any, + Dict, + IO, + List, + MutableMapping, + MutableSequence, + Optional, + Tuple, + Union, + cast, +) +from urllib.parse import urldefrag from schema_salad.exceptions import ValidationException -from schema_salad.sourceline import SourceLine -from schema_salad.utils import aslist, json_dumps +from schema_salad.sourceline import SourceLine, add_lc_filename +from schema_salad.utils import aslist, json_dumps, yaml_no_ts import cwl_utils.parser import cwl_utils.parser.cwl_v1_0 as cwl @@ -30,9 +44,9 @@ def _compare_records( This handles normalizing record names, which will be relative to workflow step, so that they can be compared. """ - srcfields = {cwl.shortname(field.name): field.type for field in (src.fields or {})} + srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} sinkfields = { - cwl.shortname(field.name): field.type for field in (sink.fields or {}) + cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) } for key in sinkfields.keys(): if ( @@ -63,10 +77,10 @@ def _compare_type(type1: Any, type2: Any) -> bool: return _compare_type(type1.items, type2.items) elif isinstance(type1, cwl.RecordSchema) and isinstance(type2, cwl.RecordSchema): fields1 = { - cwl.shortname(field.name): field.type for field in (type1.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type for field in (type2.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -82,6 +96,64 @@ def _compare_type(type1: Any, type2: Any) -> bool: return bool(type1 == type2) +def _inputfile_load( + doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + baseuri: str, + loadingOptions: cwl.LoadingOptions, + addl_metadata_fields: Optional[MutableSequence[str]] = None, +) -> Tuple[Any, cwl.LoadingOptions]: + loader = cwl.CWLInputFileLoader + if isinstance(doc, str): + url = loadingOptions.fetcher.urljoin(baseuri, doc) + if url in loadingOptions.idx: + return loadingOptions.idx[url] + doc_url, frg = urldefrag(url) + text = loadingOptions.fetcher.fetch_text(doc_url) + textIO = StringIO(text) + textIO.name = str(doc_url) + yaml = yaml_no_ts() + result = yaml.load(textIO) + add_lc_filename(result, doc_url) + loadingOptions = cwl.LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) + _inputfile_load( + result, + doc_url, + loadingOptions, + ) + return loadingOptions.idx[url] + + if isinstance(doc, MutableMapping): + addl_metadata = {} + if addl_metadata_fields is not None: + for mf in addl_metadata_fields: + if mf in doc: + addl_metadata[mf] = doc[mf] + + loadingOptions = cwl.LoadingOptions( + copyfrom=loadingOptions, + baseuri=baseuri, + addl_metadata=addl_metadata, + ) + + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions, docRoot=baseuri), + loadingOptions, + ) + + return loadingOptions.idx[baseuri] + + if isinstance(doc, MutableSequence): + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions), + loadingOptions, + ) + return loadingOptions.idx[baseuri] + + raise ValidationException( + "Expected URI string, MutableMapping or MutableSequence, got %s" % type(doc) + ) + + def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: """ Check for identical type specifications, ignoring extra keys like inputBinding. @@ -184,7 +256,7 @@ def check_types( return "exception" if linkMerge == "merge_nested": return check_types( - cwl.ArraySchema(items=srctype, type="array"), sinktype, None, None + cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None ) if linkMerge == "merge_flattened": return check_types(merge_flatten_type(srctype), sinktype, None, None) @@ -212,7 +284,7 @@ def content_limit_respected_read(f: IO[bytes]) -> str: def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: """Convert stdout and stderr type shortcuts to files.""" for out in clt.outputs: - if out.type == "stdout": + if out.type_ == "stdout": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stdout shortcut." @@ -223,9 +295,9 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stdout) - elif out.type == "stderr": + elif out.type_ == "stderr": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stderr shortcut." @@ -236,17 +308,75 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stderr) +def load_inputfile( + doc: Any, + baseuri: Optional[str] = None, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.0 input file from a serialized YAML string or a YAML object.""" + if baseuri is None: + baseuri = cwl.file_uri(os.getcwd()) + "/" + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions() + result, metadata = _inputfile_load( + doc, + baseuri, + loadingOptions, + ) + return result + + +def load_inputfile_by_string( + string: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.0 input file from a serialized YAML string.""" + yaml = yaml_no_ts() + result = yaml.load(string) + add_lc_filename(result, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + result, + uri, + loadingOptions, + ) + return result + + +def load_inputfile_by_yaml( + yaml: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.0 input file from a YAML object.""" + add_lc_filename(yaml, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + yaml, + uri, + loadingOptions, + ) + return result + + def merge_flatten_type(src: Any) -> Any: """Return the merge flattened type of the source type.""" if isinstance(src, MutableSequence): return [merge_flatten_type(t) for t in src] if isinstance(src, cwl.ArraySchema): return src - return cwl.ArraySchema(type="array", items=src) + return cwl.ArraySchema(type_="array", items=src) def type_for_step_input( @@ -264,9 +394,9 @@ def type_for_step_input( cast(str, step_input.id).split("#")[-1] == cast(str, in_.id).split("#")[-1] ): - input_type = step_input.type + input_type = step_input.type_ if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type="array") + input_type = cwl.ArraySchema(items=input_type, type_="array") return input_type return "Any" @@ -284,15 +414,15 @@ def type_for_step_output( step_output.id.split("#")[-1].split("/")[-1] == sourcename.split("#")[-1].split("/")[-1] ): - output_type = step_output.type + output_type = step_output.type_ if step.scatter is not None: if step.scatterMethod == "nested_crossproduct": for _ in range(len(aslist(step.scatter))): output_type = cwl.ArraySchema( - items=output_type, type="array" + items=output_type, type_="array" ) else: - output_type = cwl.ArraySchema(items=output_type, type="array") + output_type = cwl.ArraySchema(items=output_type, type_="array") return output_type raise ValidationException( "param {} not found in {}.".format( @@ -312,15 +442,15 @@ def type_for_source( scatter_context: List[Optional[Tuple[int, str]]] = [] params = param_for_source_id(process, sourcenames, parent, scatter_context) if not isinstance(params, list): - new_type = params.type + new_type = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") else: - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": new_type = merge_flatten_type(new_type) return new_type @@ -328,26 +458,28 @@ def type_for_source( for p, sc in zip(params, scatter_context): if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): cur_type = p - elif hasattr(p, "type") and not any(_compare_type(t, p.type) for t in new_type): - cur_type = p.type + elif hasattr(p, "type_") and not any( + _compare_type(t, p.type_) for t in new_type + ): + cur_type = p.type_ else: cur_type = None if cur_type is not None: if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") else: - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") new_type.append(cur_type) if len(new_type) == 1: new_type = new_type[0] if linkMerge == "merge_nested": - return cwl.ArraySchema(items=new_type, type="array") + return cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": return merge_flatten_type(new_type) elif isinstance(sourcenames, List) and len(sourcenames) > 1: - return cwl.ArraySchema(items=new_type, type="array") + return cwl.ArraySchema(items=new_type, type_="array") else: return new_type diff --git a/cwl_utils/parser/cwl_v1_1.py b/cwl_utils/parser/cwl_v1_1.py index f5810d57..62ccc222 100644 --- a/cwl_utils/parser/cwl_v1_1.py +++ b/cwl_utils/parser/cwl_v1_1.py @@ -11,6 +11,7 @@ import xml.sax # nosec from abc import ABC, abstractmethod from io import StringIO +from itertools import chain from typing import ( Any, Dict, @@ -59,6 +60,8 @@ class LoadingOptions: cache: CacheType imports: List[str] includes: List[str] + no_link_check: Optional[bool] + container: Optional[str] def __init__( self, @@ -73,6 +76,8 @@ def __init__( idx: Optional[IdxType] = None, imports: Optional[List[str]] = None, includes: Optional[List[str]] = None, + no_link_check: Optional[bool] = None, + container: Optional[str] = None, ) -> None: """Create a LoadingOptions object.""" self.original_doc = original_doc @@ -117,6 +122,16 @@ def __init__( else: self.includes = copyfrom.includes if copyfrom is not None else [] + if no_link_check is not None: + self.no_link_check = no_link_check + else: + self.no_link_check = copyfrom.no_link_check if copyfrom is not None else False + + if container is not None: + self.container = container + else: + self.container = copyfrom.container if copyfrom is not None else None + if fetcher is not None: self.fetcher = fetcher elif copyfrom is not None: @@ -138,10 +153,10 @@ def __init__( self.vocab = _vocab self.rvocab = _rvocab - if namespaces is not None: + if self.namespaces is not None: self.vocab = self.vocab.copy() self.rvocab = self.rvocab.copy() - for k, v in namespaces.items(): + for k, v in self.namespaces.items(): self.vocab[k] = v self.rvocab[v] = k @@ -204,8 +219,14 @@ def save( """Convert this object to a JSON/YAML friendly dictionary.""" -def load_field(val, fieldtype, baseuri, loadingOptions): - # type: (Union[str, Dict[str, str]], _Loader, str, LoadingOptions) -> Any +def load_field( + val: Union[str, Dict[str, str]], + fieldtype: "_Loader", + baseuri: str, + loadingOptions: LoadingOptions, + lc: Optional[List[Any]] = None, +) -> Any: + """Load field.""" if isinstance(val, MutableMapping): if "$import" in val: if loadingOptions.fileuri is None: @@ -224,12 +245,69 @@ def load_field(val, fieldtype, baseuri, loadingOptions): url = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) val = loadingOptions.fetcher.fetch_text(url) loadingOptions.includes.append(url) - return fieldtype.load(val, baseuri, loadingOptions) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] +def extract_type(val_type: Type[Any]) -> str: + """Take a type of value, and extracts the value as a string.""" + val_str = str(val_type) + return val_str.split("'")[1] + + +def convert_typing(val_type: str) -> str: + """Normalize type names to schema-salad types.""" + if "None" in val_type: + return "null" + if "CommentedSeq" in val_type or "list" in val_type: + return "array" + if "CommentedMap" in val_type or "dict" in val_type: + return "object" + if "False" in val_type or "True" in val_type: + return "boolean" + return val_type + + +def parse_errors(error_message: str) -> Tuple[str, str, str]: + """Parse error messages from several loaders into one error message.""" + if not error_message.startswith("Expected"): + return error_message, "", "" + vals = error_message.split("\n") + if len(vals) == 1: + return error_message, "", "" + types = set() + for val in vals: + individual_vals = val.split(" ") + if val == "": + continue + if individual_vals[1] == "one": + individual_vals = val.split("(")[1].split(",") + for t in individual_vals: + types.add(t.strip(" ").strip(")\n")) + elif individual_vals[2] == "").replace("'", "")) + elif individual_vals[0] == "Value": + types.add(individual_vals[-1].strip(".")) + else: + types.add(individual_vals[1].replace(",", "")) + types = set(val for val in types if val != "NoneType") + if "str" in types: + types = set(convert_typing(val) for val in types if "'" not in val) + to_print = "" + for val in types: + if "'" in val: + to_print = "value" if len(types) == 1 else "values" + + if to_print == "": + to_print = "type" if len(types) == 1 else "types" + + verb_tensage = "is" if len(types) == 1 else "are" + + return str(types).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage + + def save( val: Any, top: bool = True, @@ -279,14 +357,13 @@ def save_with_metadata( def expand_url( - url, # type: str - base_url, # type: str - loadingOptions, # type: LoadingOptions - scoped_id=False, # type: bool - vocab_term=False, # type: bool - scoped_ref=None, # type: Optional[int] -): - # type: (...) -> str + url: str, + base_url: str, + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: Optional[int] = None, +) -> str: if url in ("@id", "@type"): return url @@ -347,88 +424,186 @@ def expand_url( class _Loader: - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: pass class _AnyLoader(_Loader): - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") class _PrimitiveLoader(_Loader): - def __init__(self, tp): - # type: (Union[type, Tuple[Type[str], Type[str]]]) -> None + def __init__(self, tp: Union[type, Tuple[Type[str], Type[str]]]) -> None: self.tp = tp - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, self.tp): raise ValidationException( - "Expected a {} but got {}".format( - self.tp.__class__.__name__, doc.__class__.__name__ - ) + "Expected a {} but got {}".format(self.tp, doc.__class__.__name__) ) return doc - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.tp) class _ArrayLoader(_Loader): - def __init__(self, items): - # type: (_Loader) -> None + def __init__(self, items: _Loader) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableSequence): - raise ValidationException(f"Expected a list, was {type(doc)}") - r = [] # type: List[Any] - errors = [] # type: List[SchemaSaladException] + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an array." + ) + r: List[Any] = [] + errors: List[SchemaSaladException] = [] + fields: List[str] = [] for i in range(0, len(doc)): try: - lf = load_field(doc[i], _UnionLoader((self, self.items)), baseuri, loadingOptions) - if isinstance(lf, MutableSequence): + lf = load_field( + doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc + ) + flatten = loadingOptions.container != "@list" + if flatten and isinstance(lf, MutableSequence): r.extend(lf) else: r.append(lf) + + if isinstance(doc[i], CommentedMap): + if doc[i].get("id") is not None: + if doc[i].get("id") in fields: + errors.append( + ValidationException( + f"Duplicate field {doc[i].get('id')!r}", + SourceLine(doc[i], "id", str), + [], + ) + ) + else: + fields.append(doc[i].get("id")) + except ValidationException as e: - errors.append(e.with_sourceline(SourceLine(doc, i, str))) + e = ValidationException( + "array item is invalid because", SourceLine(doc, i, str), [e] + ) + errors.append(e) if errors: raise ValidationException("", None, errors) return r - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return f"array<{self.items}>" +class _MapLoader(_Loader): + def __init__( + self, + values: _Loader, + name: Optional[str] = None, + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: + self.values = values + self.name = name + self.container = container + self.no_link_check = no_link_check + + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if not isinstance(doc, MutableMapping): + raise ValidationException(f"Expected a map, was {type(doc)}") + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) + r: Dict[str, Any] = {} + errors: List[SchemaSaladException] = [] + for k, v in doc.items(): + try: + lf = load_field(v, self.values, baseuri, loadingOptions, lc) + r[k] = lf + except ValidationException as e: + errors.append(e.with_sourceline(SourceLine(doc, k, str))) + if errors: + raise ValidationException("", None, errors) + return r + + def __repr__(self) -> str: + return self.name if self.name is not None else f"map" + + class _EnumLoader(_Loader): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols = symbols self.name = name - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc in self.symbols: return doc raise ValidationException(f"Expected one of {self.symbols}") - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return self.name class _SecondaryDSLLoader(_Loader): - def __init__(self, inner): - # type: (_Loader) -> None + def __init__(self, inner: _Loader) -> None: self.inner = inner - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: r: List[Dict[str, Any]] = [] if isinstance(doc, MutableSequence): for d in doc: @@ -486,21 +661,40 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): r.append({"pattern": doc}) else: raise ValidationException("Expected str or sequence of str") - return self.inner.load(r, baseuri, loadingOptions, docRoot) + return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) class _RecordLoader(_Loader): - def __init__(self, classtype): - # type: (Type[Saveable]) -> None + def __init__( + self, + classtype: Type[Saveable], + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: self.classtype = classtype + self.container = container + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableMapping): - raise ValidationException(f"Expected a dict, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an object." + ) + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) return self.classtype.fromDoc(doc, baseuri, loadingOptions, docRoot=docRoot) - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.classtype.__name__) @@ -508,41 +702,139 @@ class _ExpressionLoader(_Loader): def __init__(self, items: Type[str]) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, str): - raise ValidationException(f"Expected a str, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is a str." + ) return doc class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader]) -> None: + def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: self.alternates = alternates + self.name = name - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def add_loaders(self, loaders: Sequence[_Loader]) -> None: + self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) + + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: errors = [] + + if lc is None: + lc = [] + for t in self.alternates: try: - return t.load(doc, baseuri, loadingOptions, docRoot=docRoot) + return t.load(doc, baseuri, loadingOptions, docRoot=docRoot, lc=lc) except ValidationException as e: - errors.append(ValidationException(f"tried {t} but", None, [e])) - raise ValidationException("", None, errors, "-") + if isinstance(t, _ArrayLoader) and len(self.alternates) > 1: + continue + if isinstance(doc, (CommentedMap, dict)): + if "class" in doc: + if str(doc.get("class")) == str(t): + errors.append( + ValidationException( + f"Object `{baseuri.split('/')[-1]}` is not valid because:", + SourceLine(doc, next(iter(doc)), str), + [e], + ) + ) + else: + if "array" in str(t): + continue + else: + if "id" in doc: + id = baseuri.split("/")[-1] + "#" + str(doc.get("id")) + if "id" in lc: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, "id", str), + [e], + ) + ) + else: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, doc.get("id"), str), + [e], + ) + ) + else: + if not isinstance( + t, (_PrimitiveLoader) + ): # avoids 'tried was {x}' errors + errors.append( + ValidationException(f"tried `{t}` but", None, [e]) + ) + else: + # avoids "tried but x" and instead returns the values for parsing + errors.append(ValidationException("", None, [e])) - def __repr__(self): # type: () -> str - return " | ".join(str(a) for a in self.alternates) + if isinstance(doc, (CommentedMap, dict)) and "class" in doc: + if str(doc.get("class")) not in str(self.alternates): + errors.append( + ValidationException( + "Field `class` contains undefined reference to " + + "`" + + "/".join(baseuri.split("/")[0:-1]) + + "/" + + str(doc.get("class")) + + "`", + SourceLine(doc, "class", str), + [], + ) + ) + raise ValidationException("", None, errors, "*") + + def __repr__(self) -> str: + return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) class _URILoader(_Loader): - def __init__(self, inner, scoped_id, vocab_term, scoped_ref): - # type: (_Loader, bool, bool, Union[int, None]) -> None + def __init__( + self, + inner: _Loader, + scoped_id: bool, + vocab_term: bool, + scoped_ref: Optional[int], + no_link_check: Optional[bool], + ) -> None: self.inner = inner self.scoped_id = scoped_id self.vocab_term = vocab_term self.scoped_ref = scoped_ref + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, no_link_check=self.no_link_check + ) if isinstance(doc, MutableSequence): newdoc = [] for i in doc: @@ -569,23 +861,33 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): self.vocab_term, self.scoped_ref, ) - return self.inner.load(doc, baseuri, loadingOptions) + if isinstance(doc, str): + if not loadingOptions.no_link_check: + errors = [] + try: + if not loadingOptions.fetcher.check_exists(doc): + errors.append( + ValidationException(f"contains undefined reference to `{doc}`") + ) + except ValidationException: + pass + if len(errors) > 0: + raise ValidationException("", None, errors) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _TypeDSLLoader(_Loader): - def __init__(self, inner, refScope, salad_version): - # type: (_Loader, Union[int, None], str) -> None + def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: self.inner = inner self.refScope = refScope self.salad_version = salad_version def resolve( self, - doc, # type: str - baseuri, # type: str - loadingOptions, # type: LoadingOptions - ): - # type: (...) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + doc: str, + baseuri: str, + loadingOptions: LoadingOptions, + ) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str]: doc_ = doc optional = False if doc_.endswith("?"): @@ -594,7 +896,7 @@ def resolve( if doc_.endswith("[]"): salad_versions = [int(v) for v in self.salad_version[1:].split(".")] - items = "" # type: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + items: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] = "" rest = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): @@ -606,7 +908,7 @@ def resolve( items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded = {"type": "array", "items": items} # type: Union[Dict[str, Any], str] + expanded: Union[Dict[str, Any], str] = {"type": "array", "items": items} else: expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) @@ -615,10 +917,16 @@ def resolve( else: return expanded - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableSequence): - r = [] # type: List[Any] + r: List[Any] = [] for d in doc: if isinstance(d, str): resolved = self.resolve(d, baseuri, loadingOptions) @@ -635,20 +943,25 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): elif isinstance(doc, str): doc = self.resolve(doc, baseuri, loadingOptions) - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _IdMapLoader(_Loader): - def __init__(self, inner, mapSubject, mapPredicate): - # type: (_Loader, str, Union[str, None]) -> None + def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: self.inner = inner self.mapSubject = mapSubject self.mapPredicate = mapPredicate - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableMapping): - r = [] # type: List[Any] + r: List[Any] = [] for k in sorted(doc.keys()): val = doc[k] if isinstance(val, CommentedMap): @@ -669,7 +982,7 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): else: raise ValidationException("No mapPredicate") doc = r - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) def _document_load( @@ -706,7 +1019,13 @@ def _document_load( addl_metadata=addl_metadata, ) - doc = {k: v for k, v in doc.items() if k not in ("$namespaces", "$schemas", "$base")} + doc = copy.copy(doc) + if "$namespaces" in doc: + doc.pop("$namespaces") + if "$schemas" in doc: + doc.pop("$schemas") + if "$base" in doc: + doc.pop("$base") if "$graph" in doc: loadingOptions.idx[baseuri] = ( @@ -767,7 +1086,8 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path, split_frag=False): # type: (str, bool) -> str +def file_uri(path: str, split_frag: bool = False) -> str: + """Transform a file path into a URL with file scheme.""" if path.startswith("file://"): return path if split_frag: @@ -857,12 +1177,11 @@ class RecordField(Documented): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -873,19 +1192,19 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordField): return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type)) + return hash((self.doc, self.name, self.type_)) @classmethod def fromDoc( @@ -893,9 +1212,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -904,18 +1224,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -924,7 +1268,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -934,36 +1278,91 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -977,14 +1376,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1009,9 +1407,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1028,12 +1426,11 @@ def save( class RecordSchema(Saveable): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1043,15 +1440,15 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordSchema): - return bool(self.fields == other.fields and self.type == other.type) + return bool(self.fields == other.fields and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.fields, self.type)) + return hash((self.fields, self.type_)) @classmethod def fromDoc( @@ -1059,9 +1456,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -1073,36 +1471,91 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1116,13 +1569,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1143,9 +1595,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1168,11 +1620,11 @@ class EnumSchema(Saveable): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1181,16 +1633,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, EnumSchema): - return bool(self.symbols == other.symbols and self.type == other.type) + return bool( + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ + ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type)) + return hash((self.name, self.symbols, self.type_)) @classmethod def fromDoc( @@ -1198,70 +1655,181 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - symbols = load_field( - _doc.get("symbols"), - uri_array_of_strtype_True_False_None, - baseuri, - loadingOptions, - ) - except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], - ) - ) - try: - type = load_field( - _doc.get("type"), - typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2, - baseuri, - loadingOptions, - ) - except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") ) - ) - extension_fields: Dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = name + try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + + symbols = load_field( + _doc.get("symbols"), + uri_array_of_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("symbols") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Enum_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[name] = (_constructed, loadingOptions) return _constructed def save( @@ -1275,12 +1843,15 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u if self.symbols is not None: - u = save_relative_uri(self.symbols, base_url, True, None, relative_uris) + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1291,18 +1862,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type"]) + attrs = frozenset(["name", "symbols", "type"]) class ArraySchema(Saveable): def __init__( self, items: Any, - type: Any, + type_: Any, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1312,15 +1882,15 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type == other.type) + return bool(self.items == other.items and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.items, self.type)) + return hash((self.items, self.type_)) @classmethod def fromDoc( @@ -1328,47 +1898,1104 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2, + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class MapSchema(Saveable): + def __init__( + self, + type_: Any, + values: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.type_ = type_ + self.values = values + + def __eq__(self, other: Any) -> bool: + if isinstance(other, MapSchema): + return bool(self.type_ == other.type_ and self.values == other.values) + return False + + def __hash__(self) -> int: + return hash((self.type_, self.values)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "MapSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Map_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + try: + if _doc.get("values") is None: + raise ValidationException("missing required field `values`", None, []) + + values = load_field( + _doc.get("values"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("values") ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `values`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("values")))) + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `type`, `values`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + type_=type_, + values=values, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.values is not None: + u = save_relative_uri(self.values, base_url, False, 2, relative_uris) + r["values"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["type", "values"]) + + +class UnionSchema(Saveable): + def __init__( + self, + names: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.names = names + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, UnionSchema): + return bool(self.names == other.names and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.names, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "UnionSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("names") is None: + raise ValidationException("missing required field `names`", None, []) + + names = load_field( + _doc.get("names"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("names") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `names`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("names")))) + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Union_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `names`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + names=names, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.names is not None: + u = save_relative_uri(self.names, base_url, False, 2, relative_uris) + r["names"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["names", "type"]) + + +class CWLArraySchema(ArraySchema): + def __init__( + self, + items: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLArraySchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class CWLRecordField(RecordField): + def __init__( + self, + name: Any, + type_: Any, + doc: Optional[Any] = None, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + ) + return False + + def __hash__(self) -> int: + return hash((self.doc, self.name, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLRecordField": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + _errors__.append(ValidationException("missing name")) + if not __original_name_is_none: + baseuri = name + if "doc" in _doc: + try: + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) + else: + doc = None + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + doc=doc, + name=name, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["doc", "name", "type"]) + + +class CWLRecordSchema(RecordSchema): + def __init__( + self, + type_: Any, + fields: Optional[Any] = None, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.fields = fields + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLRecordSchema): + return bool(self.fields == other.fields and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.fields, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLRecordSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + if "fields" in _doc: + try: + fields = load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) + else: + fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1376,19 +3003,18 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `fields`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type=type, + fields=fields, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1405,13 +3031,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=base_url, relative_uris=relative_uris + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1422,7 +3048,7 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) + attrs = frozenset(["fields", "type"]) class File(Saveable): @@ -1512,7 +3138,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1576,51 +3201,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "File": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "File": - raise ValidationException("Not a File") + raise ValidationException("tried `File` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -1630,15 +3306,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "dirname" in _doc: @@ -1648,15 +3348,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dirname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dirname' field is not valid because:", - SourceLine(_doc, "dirname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dirname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dirname")))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + ) + ) else: dirname = None if "nameroot" in _doc: @@ -1666,15 +3390,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameroot") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameroot' field is not valid because:", - SourceLine(_doc, "nameroot", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameroot`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameroot")))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + ) + ) else: nameroot = None if "nameext" in _doc: @@ -1684,15 +3432,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameext") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameext' field is not valid because:", - SourceLine(_doc, "nameext", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameext`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameext")))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + ) + ) else: nameext = None if "checksum" in _doc: @@ -1702,15 +3474,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("checksum") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'checksum' field is not valid because:", - SourceLine(_doc, "checksum", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `checksum`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("checksum")))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + ) + ) else: checksum = None if "size" in _doc: @@ -1720,15 +3516,39 @@ def fromDoc( union_of_None_type_or_inttype, baseuri, loadingOptions, + lc=_doc.get("size") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'size' field is not valid because:", - SourceLine(_doc, "size", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("size")))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + ) + ) else: size = None if "secondaryFiles" in _doc: @@ -1738,33 +3558,81 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "contents" in _doc: @@ -1774,21 +3642,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("contents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'contents' field is not valid because:", - SourceLine(_doc, "contents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("contents")))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + ) + ) else: contents = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1802,10 +3698,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'File'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -1964,7 +3859,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2001,51 +3895,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Directory": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Directory": - raise ValidationException("Not a Directory") + raise ValidationException("tried `Directory` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -2055,15 +4000,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "listing" in _doc: @@ -2073,21 +4042,49 @@ def fromDoc( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) else: listing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2101,10 +4098,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Directory'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -2194,7 +4190,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2219,9 +4214,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2233,21 +4229,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2261,10 +4285,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, extension_fields=extension_fields, @@ -2314,11 +4337,11 @@ class OutputSchema(IOSchema): pass -class InputRecordField(RecordField, FieldBase, InputFormat, LoadContents): +class InputRecordField(CWLRecordField, FieldBase, InputFormat, LoadContents): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -2329,7 +4352,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2340,7 +4362,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -2353,7 +4375,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -2368,7 +4390,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -2384,9 +4406,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2395,18 +4418,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2415,7 +4462,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -2425,32 +4472,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2458,15 +4556,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -2476,15 +4598,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -2494,33 +4640,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -2530,15 +4724,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -2548,21 +4766,49 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2576,14 +4822,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -2614,9 +4859,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2677,10 +4922,10 @@ def save( ) -class InputRecordSchema(RecordSchema, InputSchema): +class InputRecordSchema(CWLRecordSchema, InputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -2688,7 +4933,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2698,7 +4942,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -2707,7 +4951,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -2715,7 +4959,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -2723,9 +4967,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2734,18 +4979,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2764,32 +5033,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2797,15 +5117,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -2815,21 +5159,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2843,13 +5215,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -2877,9 +5248,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2905,14 +5276,13 @@ class InputEnumSchema(EnumSchema, InputSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, - name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2921,25 +5291,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc - self.name = name def __eq__(self, other: Any) -> bool: if isinstance(other, InputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.doc, self.name)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -2947,9 +5317,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2958,18 +5329,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2982,35 +5377,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3018,15 +5467,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3036,21 +5509,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3058,22 +5559,21 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `doc`, `name`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -3097,9 +5597,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3118,21 +5618,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "doc", "name"]) + attrs = frozenset(["name", "symbols", "type", "label", "doc"]) -class InputArraySchema(ArraySchema, InputSchema): +class InputArraySchema(CWLArraySchema, InputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3142,7 +5641,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -3151,7 +5650,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -3159,7 +5658,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -3167,9 +5666,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3178,18 +5678,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3202,35 +5726,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3238,15 +5816,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3256,21 +5858,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3284,13 +5914,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -3315,12 +5944,11 @@ def save( u = save_relative_uri(self.name, base_url, True, None, relative_uris) r["name"] = u if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3342,11 +5970,11 @@ def save( attrs = frozenset(["items", "type", "label", "doc", "name"]) -class OutputRecordField(RecordField, FieldBase, OutputFormat): +class OutputRecordField(CWLRecordField, FieldBase, OutputFormat): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -3355,7 +5983,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3366,7 +5993,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -3377,7 +6004,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -3390,7 +6017,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -3404,9 +6031,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3415,18 +6043,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3435,7 +6087,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -3445,32 +6097,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3478,15 +6181,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -3496,15 +6223,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -3514,39 +6265,91 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3560,14 +6363,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -3596,9 +6398,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3635,10 +6437,10 @@ def save( ) -class OutputRecordSchema(RecordSchema, OutputSchema): +class OutputRecordSchema(CWLRecordSchema, OutputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -3646,7 +6448,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3656,7 +6457,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -3665,7 +6466,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, OutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -3673,7 +6474,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -3681,9 +6482,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3692,18 +6494,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3722,32 +6548,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3755,15 +6632,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3773,21 +6674,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3801,13 +6730,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -3835,9 +6763,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3863,14 +6791,13 @@ class OutputEnumSchema(EnumSchema, OutputSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, - name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3879,25 +6806,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc - self.name = name def __eq__(self, other: Any) -> bool: if isinstance(other, OutputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.doc, self.name)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -3905,9 +6832,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3916,18 +6844,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3940,35 +6892,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3976,15 +6982,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3994,21 +7024,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4016,22 +7074,21 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `doc`, `name`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -4055,9 +7112,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -4076,21 +7133,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "doc", "name"]) + attrs = frozenset(["name", "symbols", "type", "label", "doc"]) -class OutputArraySchema(ArraySchema, OutputSchema): +class OutputArraySchema(CWLArraySchema, OutputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4100,7 +7156,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -4109,7 +7165,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, OutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -4117,7 +7173,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -4125,9 +7181,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -4136,18 +7193,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -4160,35 +7241,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -4196,15 +7331,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -4214,21 +7373,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4242,13 +7429,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -4273,12 +7459,11 @@ def save( u = save_relative_uri(self.name, base_url, True, None, relative_uris) r["name"] = u if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -4348,7 +7533,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4377,16 +7561,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InlineJavascriptRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InlineJavascriptRequirement": - raise ValidationException("Not a InlineJavascriptRequirement") + raise ValidationException("tried `InlineJavascriptRequirement` but") if "expressionLib" in _doc: try: @@ -4395,21 +7582,49 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("expressionLib") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expressionLib' field is not valid because:", - SourceLine(_doc, "expressionLib", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expressionLib`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expressionLib")))) + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [e], + ) + ) else: expressionLib = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4423,12 +7638,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InlineJavascriptRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( expressionLib=expressionLib, extension_fields=extension_fields, @@ -4490,7 +7702,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4516,36 +7727,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SchemaDefRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SchemaDefRequirement": - raise ValidationException("Not a SchemaDefRequirement") + raise ValidationException("tried `SchemaDefRequirement` but") try: + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) + types = load_field( _doc.get("types"), array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, baseuri, loadingOptions, + lc=_doc.get("types") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'types' field is not valid because:", - SourceLine(_doc, "types", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `types`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("types")))) + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4559,10 +7804,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SchemaDefRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( types=types, extension_fields=extension_fields, @@ -4607,7 +7851,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4635,28 +7878,56 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SecondaryFileSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("pattern") is None: + raise ValidationException("missing required field `pattern`", None, []) + pattern = load_field( _doc.get("pattern"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("pattern") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'pattern' field is not valid because:", - SourceLine(_doc, "pattern", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `pattern`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("pattern")))) + _errors__.append( + ValidationException( + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), + [e], + ) + ) if "required" in _doc: try: required = load_field( @@ -4664,21 +7935,49 @@ def fromDoc( union_of_None_type_or_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("required") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'required' field is not valid because:", - SourceLine(_doc, "required", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `required`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("required")))) + _errors__.append( + ValidationException( + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), + [e], + ) + ) else: required = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4692,10 +7991,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SecondaryFileSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( pattern=pattern, required=required, @@ -4748,7 +8046,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4776,16 +8073,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "LoadListingRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "LoadListingRequirement": - raise ValidationException("Not a LoadListingRequirement") + raise ValidationException("tried `LoadListingRequirement` but") if "loadListing" in _doc: try: @@ -4794,21 +8094,49 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4822,12 +8150,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'LoadListingRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadListing=loadListing, extension_fields=extension_fields, @@ -4882,7 +8207,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4910,47 +8234,106 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvironmentDef": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) + envName = load_field( _doc.get("envName"), strtype, baseuri, loadingOptions, + lc=_doc.get("envName") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envName' field is not valid because:", - SourceLine(_doc, "envName", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envName`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envName")))) + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [e], + ) + ) try: + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) + envValue = load_field( _doc.get("envValue"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("envValue") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envValue' field is not valid because:", - SourceLine(_doc, "envValue", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envValue`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envValue")))) + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4964,10 +8347,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvironmentDef'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envName=envName, envValue=envValue, @@ -5059,7 +8441,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5108,9 +8489,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5122,15 +8504,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "position" in _doc: @@ -5140,15 +8546,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("position") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'position' field is not valid because:", - SourceLine(_doc, "position", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("position")))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + ) + ) else: position = None if "prefix" in _doc: @@ -5158,15 +8588,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("prefix") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'prefix' field is not valid because:", - SourceLine(_doc, "prefix", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `prefix`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("prefix")))) + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [e], + ) + ) else: prefix = None if "separate" in _doc: @@ -5176,15 +8630,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("separate") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'separate' field is not valid because:", - SourceLine(_doc, "separate", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `separate`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("separate")))) + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [e], + ) + ) else: separate = None if "itemSeparator" in _doc: @@ -5194,15 +8672,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("itemSeparator") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'itemSeparator' field is not valid because:", - SourceLine(_doc, "itemSeparator", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `itemSeparator`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("itemSeparator")))) + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [e], + ) + ) else: itemSeparator = None if "valueFrom" in _doc: @@ -5212,15 +8714,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None if "shellQuote" in _doc: @@ -5230,21 +8756,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("shellQuote") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'shellQuote' field is not valid because:", - SourceLine(_doc, "shellQuote", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `shellQuote`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("shellQuote")))) + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [e], + ) + ) else: shellQuote = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5258,10 +8812,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, position=position, @@ -5372,7 +8925,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5405,9 +8957,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5419,15 +8972,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -5437,15 +9014,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "glob" in _doc: @@ -5455,15 +9056,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("glob") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'glob' field is not valid because:", - SourceLine(_doc, "glob", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `glob`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("glob")))) + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [e], + ) + ) else: glob = None if "outputEval" in _doc: @@ -5473,21 +9098,49 @@ def fromDoc( union_of_None_type_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outputEval") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputEval' field is not valid because:", - SourceLine(_doc, "outputEval", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputEval`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputEval")))) + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [e], + ) + ) else: outputEval = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5501,10 +9154,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandOutputBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, loadListing=loadListing, @@ -5570,7 +9222,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5595,9 +9246,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineBindable": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5609,21 +9261,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5637,10 +9317,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineBindable'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( inputBinding=inputBinding, extension_fields=extension_fields, @@ -5682,7 +9361,7 @@ class CommandInputRecordField(InputRecordField, CommandLineBindable): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -5694,7 +9373,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5705,7 +9383,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -5719,7 +9397,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -5735,7 +9413,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -5752,9 +9430,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5763,18 +9442,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -5783,7 +9486,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -5793,32 +9496,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -5826,15 +9580,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -5844,15 +9622,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -5862,33 +9664,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -5898,15 +9748,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -5916,15 +9790,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "inputBinding" in _doc: @@ -5934,21 +9832,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5962,16 +9888,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -6003,9 +9926,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6079,7 +10002,7 @@ class CommandInputRecordSchema( ): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -6088,7 +10011,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6098,7 +10020,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -6108,7 +10030,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -6118,7 +10040,14 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( - (self.fields, self.type, self.label, self.doc, self.name, self.inputBinding) + ( + self.fields, + self.type_, + self.label, + self.doc, + self.name, + self.inputBinding, + ) ) @classmethod @@ -6127,9 +10056,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6138,18 +10068,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6168,32 +10122,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6201,15 +10206,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6219,15 +10248,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6237,21 +10290,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6265,15 +10346,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -6302,9 +10380,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6337,15 +10415,14 @@ class CommandInputEnumSchema(InputEnumSchema, CommandInputSchema, CommandLineBin def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, - name: Optional[Any] = None, inputBinding: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6354,21 +10431,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc - self.name = name self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name and self.inputBinding == other.inputBinding ) return False @@ -6376,11 +10453,11 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( ( + self.name, self.symbols, - self.type, + self.type_, self.label, self.doc, - self.name, self.inputBinding, ) ) @@ -6391,9 +10468,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6402,18 +10480,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6426,35 +10528,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6462,15 +10618,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6480,15 +10660,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6498,21 +10702,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6520,24 +10752,21 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `doc`, `name`, `inputBinding`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`, `inputBinding`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, - name=name, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -6562,9 +10791,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6590,7 +10819,7 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "doc", "name", "inputBinding"]) + attrs = frozenset(["name", "symbols", "type", "label", "doc", "inputBinding"]) class CommandInputArraySchema( @@ -6599,7 +10828,7 @@ class CommandInputArraySchema( def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, @@ -6607,7 +10836,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6617,7 +10845,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -6627,7 +10855,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -6637,7 +10865,7 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( - (self.items, self.type, self.label, self.doc, self.name, self.inputBinding) + (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) ) @classmethod @@ -6646,9 +10874,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6657,18 +10886,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6681,35 +10934,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6717,15 +11024,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6735,15 +11066,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6753,21 +11108,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6781,15 +11164,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -6815,12 +11195,11 @@ def save( u = save_relative_uri(self.name, base_url, True, None, relative_uris) r["name"] = u if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6853,7 +11232,7 @@ class CommandOutputRecordField(OutputRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -6863,7 +11242,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6874,7 +11252,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -6886,7 +11264,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -6900,7 +11278,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -6915,9 +11293,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6926,18 +11305,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6946,7 +11349,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -6956,32 +11359,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6989,15 +11443,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -7007,15 +11485,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -7025,33 +11527,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "outputBinding" in _doc: @@ -7061,21 +11611,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7089,16 +11667,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -7128,9 +11703,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7186,7 +11761,7 @@ def save( class CommandOutputRecordSchema(OutputRecordSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -7194,7 +11769,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7204,7 +11778,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -7213,7 +11787,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -7221,7 +11795,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -7229,9 +11803,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7240,18 +11815,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7270,32 +11869,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7303,15 +11953,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7321,21 +11995,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7349,15 +12051,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -7385,9 +12084,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7413,14 +12112,13 @@ class CommandOutputEnumSchema(OutputEnumSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, + name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, - name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7429,25 +12127,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() + self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc - self.name = name def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputEnumSchema): return bool( - self.symbols == other.symbols - and self.type == other.type + self.name == other.name + and self.symbols == other.symbols + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc - and self.name == other.name ) return False def __hash__(self) -> int: - return hash((self.symbols, self.type, self.label, self.doc, self.name)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -7455,9 +12153,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7466,18 +12165,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7490,35 +12213,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2, + typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7526,15 +12303,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7544,21 +12345,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7566,24 +12395,21 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `symbols`, `type`, `label`, `doc`, `name`".format( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`, `label`, `doc`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, - name=name, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -7607,9 +12433,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7628,21 +12454,20 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["symbols", "type", "label", "doc", "name"]) + attrs = frozenset(["name", "symbols", "type", "label", "doc"]) class CommandOutputArraySchema(OutputArraySchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7652,7 +12477,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -7661,7 +12486,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -7669,7 +12494,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -7677,9 +12502,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7688,18 +12514,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7712,35 +12562,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2, + typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7748,15 +12652,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7766,21 +12694,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7794,15 +12750,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -7827,12 +12780,11 @@ def save( u = save_relative_uri(self.name, base_url, True, None, relative_uris) r["name"] = u if self.items is not None: - r["items"] = save( - self.items, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.type is not None: + u = save_relative_uri(self.items, self.name, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7861,7 +12813,7 @@ class CommandInputParameter(InputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -7875,7 +12827,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7893,7 +12844,7 @@ def __init__( self.loadContents = loadContents self.loadListing = loadListing self.default = default - self.type = type + self.type_ = type_ self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: @@ -7908,7 +12859,7 @@ def __eq__(self, other: Any) -> bool: and self.loadContents == other.loadContents and self.loadListing == other.loadListing and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ and self.inputBinding == other.inputBinding ) return False @@ -7925,7 +12876,7 @@ def __hash__(self) -> int: self.loadContents, self.loadListing, self.default, - self.type, + self.type_, self.inputBinding, ) ) @@ -7936,9 +12887,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7947,18 +12899,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -7977,15 +12953,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -7995,15 +12995,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -8013,15 +13037,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -8031,33 +13079,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -8067,15 +13163,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -8085,50 +13205,125 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -8136,21 +13331,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8164,10 +13387,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandInputParameter'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -8178,7 +13400,7 @@ def fromDoc( loadContents=loadContents, loadListing=loadListing, default=default, - type=type, + type_=type_, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -8243,9 +13465,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -8287,7 +13509,7 @@ class CommandOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -8298,7 +13520,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8313,7 +13534,7 @@ def __init__( self.doc = doc self.id = id self.format = format - self.type = type + self.type_ = type_ self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: @@ -8325,7 +13546,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ and self.outputBinding == other.outputBinding ) return False @@ -8339,7 +13560,7 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.type, + self.type_, self.outputBinding, ) ) @@ -8350,9 +13571,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -8361,18 +13583,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -8391,15 +13637,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -8409,15 +13679,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -8427,15 +13721,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -8445,50 +13763,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "outputBinding" in _doc: try: outputBinding = load_field( @@ -8496,21 +13889,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8524,12 +13945,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -8537,7 +13955,7 @@ def fromDoc( doc=doc, id=id, format=format, - type=type, + type_=type_, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -8584,9 +14002,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( @@ -8645,7 +14063,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8724,33 +14141,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "CommandLineTool": - raise ValidationException("Not a CommandLineTool") + raise ValidationException("tried `CommandLineTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -8769,15 +14213,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -8787,47 +14255,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_CommandInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_CommandOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -8835,15 +14381,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -8853,33 +14423,81 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "baseCommand" in _doc: @@ -8889,15 +14507,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("baseCommand") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'baseCommand' field is not valid because:", - SourceLine(_doc, "baseCommand", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `baseCommand`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("baseCommand")))) + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [e], + ) + ) else: baseCommand = None if "arguments" in _doc: @@ -8907,15 +14549,39 @@ def fromDoc( union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("arguments") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'arguments' field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `arguments`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("arguments")))) + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [e], + ) + ) else: arguments = None if "stdin" in _doc: @@ -8925,15 +14591,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdin' field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdin")))) + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [e], + ) + ) else: stdin = None if "stderr" in _doc: @@ -8943,15 +14633,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stderr") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stderr' field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stderr`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stderr")))) + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [e], + ) + ) else: stderr = None if "stdout" in _doc: @@ -8961,15 +14675,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdout") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdout' field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdout`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdout")))) + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [e], + ) + ) else: stdout = None if "successCodes" in _doc: @@ -8979,15 +14717,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("successCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'successCodes' field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `successCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("successCodes")))) + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [e], + ) + ) else: successCodes = None if "temporaryFailCodes" in _doc: @@ -8997,15 +14759,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("temporaryFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'temporaryFailCodes' field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `temporaryFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("temporaryFailCodes")))) + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [e], + ) + ) else: temporaryFailCodes = None if "permanentFailCodes" in _doc: @@ -9015,21 +14801,49 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("permanentFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'permanentFailCodes' field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `permanentFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("permanentFailCodes")))) + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [e], + ) + ) else: permanentFailCodes = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9043,10 +14857,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -9259,7 +15072,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9308,16 +15120,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "DockerRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "DockerRequirement": - raise ValidationException("Not a DockerRequirement") + raise ValidationException("tried `DockerRequirement` but") if "dockerPull" in _doc: try: @@ -9326,15 +15141,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerPull") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerPull' field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerPull`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerPull")))) + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [e], + ) + ) else: dockerPull = None if "dockerLoad" in _doc: @@ -9344,15 +15183,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerLoad") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerLoad' field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerLoad`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerLoad")))) + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [e], + ) + ) else: dockerLoad = None if "dockerFile" in _doc: @@ -9362,15 +15225,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerFile") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerFile' field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerFile`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerFile")))) + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [e], + ) + ) else: dockerFile = None if "dockerImport" in _doc: @@ -9380,15 +15267,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImport") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImport' field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImport`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImport")))) + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [e], + ) + ) else: dockerImport = None if "dockerImageId" in _doc: @@ -9398,15 +15309,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImageId") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImageId' field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImageId`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImageId")))) + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [e], + ) + ) else: dockerImageId = None if "dockerOutputDirectory" in _doc: @@ -9416,21 +15351,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerOutputDirectory") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerOutputDirectory' field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerOutputDirectory`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerOutputDirectory")))) + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [e], + ) + ) else: dockerOutputDirectory = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9444,10 +15407,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'DockerRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( dockerPull=dockerPull, dockerLoad=dockerLoad, @@ -9550,7 +15512,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9576,36 +15537,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwareRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SoftwareRequirement": - raise ValidationException("Not a SoftwareRequirement") + raise ValidationException("tried `SoftwareRequirement` but") try: + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) + packages = load_field( _doc.get("packages"), idmap_packages_array_of_SoftwarePackageLoader, baseuri, loadingOptions, + lc=_doc.get("packages") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'packages' field is not valid because:", - SourceLine(_doc, "packages", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `packages`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("packages")))) + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9619,10 +15614,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwareRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( packages=packages, extension_fields=extension_fields, @@ -9668,7 +15662,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9699,28 +15692,56 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwarePackage": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) + package = load_field( _doc.get("package"), strtype, baseuri, loadingOptions, + lc=_doc.get("package") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'package' field is not valid because:", - SourceLine(_doc, "package", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `package`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("package")))) + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [e], + ) + ) if "version" in _doc: try: version = load_field( @@ -9728,39 +15749,91 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("version") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'version' field is not valid because:", - SourceLine(_doc, "version", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `version`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("version")))) + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [e], + ) + ) else: version = None if "specs" in _doc: try: specs = load_field( _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None, + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, baseuri, loadingOptions, + lc=_doc.get("specs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'specs' field is not valid because:", - SourceLine(_doc, "specs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `specs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("specs")))) + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [e], + ) + ) else: specs = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9774,10 +15847,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwarePackage'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( package=package, version=version, @@ -9838,7 +15910,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9869,9 +15940,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Dirent": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -9883,32 +15955,83 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entryname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entryname' field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entryname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entryname")))) + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [e], + ) + ) else: entryname = None try: + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) + entry = load_field( _doc.get("entry"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entry") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entry' field is not valid because:", - SourceLine(_doc, "entry", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entry`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entry")))) + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [e], + ) + ) if "writable" in _doc: try: writable = load_field( @@ -9916,21 +16039,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("writable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'writable' field is not valid because:", - SourceLine(_doc, "writable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `writable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("writable")))) + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [e], + ) + ) else: writable = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9944,10 +16095,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Dirent'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( entryname=entryname, entry=entry, @@ -10006,7 +16156,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10032,36 +16181,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InitialWorkDirRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InitialWorkDirRequirement": - raise ValidationException("Not a InitialWorkDirRequirement") + raise ValidationException("tried `InitialWorkDirRequirement` but") try: + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) + listing = load_field( _doc.get("listing"), union_of_array_of_union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10075,12 +16258,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InitialWorkDirRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( listing=listing, extension_fields=extension_fields, @@ -10130,7 +16310,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10156,36 +16335,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvVarRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "EnvVarRequirement": - raise ValidationException("Not a EnvVarRequirement") + raise ValidationException("tried `EnvVarRequirement` but") try: + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) + envDef = load_field( _doc.get("envDef"), idmap_envDef_array_of_EnvironmentDefLoader, baseuri, loadingOptions, + lc=_doc.get("envDef") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envDef' field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envDef`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envDef")))) + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10199,10 +16412,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvVarRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envDef=envDef, extension_fields=extension_fields, @@ -10256,7 +16468,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10281,21 +16492,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ShellCommandRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ShellCommandRequirement": - raise ValidationException("Not a ShellCommandRequirement") + raise ValidationException("tried `ShellCommandRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10307,12 +16525,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ShellCommandRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -10382,7 +16597,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10437,16 +16651,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ResourceRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ResourceRequirement": - raise ValidationException("Not a ResourceRequirement") + raise ValidationException("tried `ResourceRequirement` but") if "coresMin" in _doc: try: @@ -10455,15 +16672,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMin' field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMin")))) + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [e], + ) + ) else: coresMin = None if "coresMax" in _doc: @@ -10473,15 +16714,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMax' field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMax")))) + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [e], + ) + ) else: coresMax = None if "ramMin" in _doc: @@ -10491,15 +16756,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMin' field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMin")))) + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [e], + ) + ) else: ramMin = None if "ramMax" in _doc: @@ -10509,15 +16798,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMax' field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMax")))) + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [e], + ) + ) else: ramMax = None if "tmpdirMin" in _doc: @@ -10527,15 +16840,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMin' field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMin")))) + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [e], + ) + ) else: tmpdirMin = None if "tmpdirMax" in _doc: @@ -10545,15 +16882,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMax' field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMax")))) + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [e], + ) + ) else: tmpdirMax = None if "outdirMin" in _doc: @@ -10563,15 +16924,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMin' field is not valid because:", - SourceLine(_doc, "outdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMin")))) + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [e], + ) + ) else: outdirMin = None if "outdirMax" in _doc: @@ -10581,21 +16966,49 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMax' field is not valid because:", - SourceLine(_doc, "outdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMax")))) + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [e], + ) + ) else: outdirMax = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10609,10 +17022,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ResourceRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( coresMin=coresMin, coresMax=coresMax, @@ -10728,7 +17140,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10756,36 +17167,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkReuse": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "WorkReuse": - raise ValidationException("Not a WorkReuse") + raise ValidationException("tried `WorkReuse` but") try: + if _doc.get("enableReuse") is None: + raise ValidationException("missing required field `enableReuse`", None, []) + enableReuse = load_field( _doc.get("enableReuse"), union_of_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("enableReuse") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'enableReuse' field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `enableReuse`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("enableReuse")))) + _errors__.append( + ValidationException( + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10799,10 +17244,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkReuse'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( enableReuse=enableReuse, extension_fields=extension_fields, @@ -10868,7 +17312,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10897,36 +17340,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "NetworkAccess": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "NetworkAccess": - raise ValidationException("Not a NetworkAccess") + raise ValidationException("tried `NetworkAccess` but") try: + if _doc.get("networkAccess") is None: + raise ValidationException("missing required field `networkAccess`", None, []) + networkAccess = load_field( _doc.get("networkAccess"), union_of_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("networkAccess") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'networkAccess' field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `networkAccess`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("networkAccess")))) + _errors__.append( + ValidationException( + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10940,10 +17417,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'NetworkAccess'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( networkAccess=networkAccess, extension_fields=extension_fields, @@ -11024,7 +17500,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11053,36 +17528,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InplaceUpdateRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InplaceUpdateRequirement": - raise ValidationException("Not a InplaceUpdateRequirement") + raise ValidationException("tried `InplaceUpdateRequirement` but") try: + if _doc.get("inplaceUpdate") is None: + raise ValidationException("missing required field `inplaceUpdate`", None, []) + inplaceUpdate = load_field( _doc.get("inplaceUpdate"), booltype, baseuri, loadingOptions, + lc=_doc.get("inplaceUpdate") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inplaceUpdate' field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inplaceUpdate`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inplaceUpdate")))) + _errors__.append( + ValidationException( + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11096,12 +17605,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InplaceUpdateRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( inplaceUpdate=inplaceUpdate, extension_fields=extension_fields, @@ -11159,7 +17665,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11187,36 +17692,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ToolTimeLimit": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ToolTimeLimit": - raise ValidationException("Not a ToolTimeLimit") + raise ValidationException("tried `ToolTimeLimit` but") try: + if _doc.get("timelimit") is None: + raise ValidationException("missing required field `timelimit`", None, []) + timelimit = load_field( _doc.get("timelimit"), union_of_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("timelimit") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'timelimit' field is not valid because:", - SourceLine(_doc, "timelimit", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `timelimit`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("timelimit")))) + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11230,10 +17769,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ToolTimeLimit'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( timelimit=timelimit, extension_fields=extension_fields, @@ -11276,7 +17814,7 @@ def save( class ExpressionToolOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -11286,7 +17824,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11301,7 +17838,7 @@ def __init__( self.doc = doc self.id = id self.format = format - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, ExpressionToolOutputParameter): @@ -11312,7 +17849,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -11325,7 +17862,7 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.type, + self.type_, ) ) @@ -11335,9 +17872,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionToolOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11346,18 +17884,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11376,15 +17938,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -11394,15 +17980,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -11412,15 +18022,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -11430,54 +18064,133 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11491,12 +18204,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ExpressionToolOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -11504,7 +18214,7 @@ def fromDoc( doc=doc, id=id, format=format, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -11550,9 +18260,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -11571,7 +18281,7 @@ def save( class WorkflowInputParameter(InputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -11585,7 +18295,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11603,7 +18312,7 @@ def __init__( self.loadContents = loadContents self.loadListing = loadListing self.default = default - self.type = type + self.type_ = type_ self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: @@ -11618,7 +18327,7 @@ def __eq__(self, other: Any) -> bool: and self.loadContents == other.loadContents and self.loadListing == other.loadListing and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ and self.inputBinding == other.inputBinding ) return False @@ -11635,7 +18344,7 @@ def __hash__(self) -> int: self.loadContents, self.loadListing, self.default, - self.type, + self.type_, self.inputBinding, ) ) @@ -11646,9 +18355,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11657,18 +18367,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11687,15 +18421,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -11705,15 +18463,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -11723,15 +18505,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -11741,33 +18547,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -11777,15 +18631,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -11795,50 +18673,125 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -11846,21 +18799,49 @@ def fromDoc( union_of_None_type_or_InputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11874,12 +18855,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'WorkflowInputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -11890,7 +18868,7 @@ def fromDoc( loadContents=loadContents, loadListing=loadListing, default=default, - type=type, + type_=type_, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -11955,9 +18933,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -12018,7 +18996,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12076,33 +19053,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ExpressionTool": - raise ValidationException("Not a ExpressionTool") + raise ValidationException("tried `ExpressionTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -12121,15 +19125,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -12139,47 +19167,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_ExpressionToolOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -12187,15 +19293,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -12205,54 +19335,133 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None try: + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) + expression = load_field( _doc.get("expression"), ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("expression") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expression' field is not valid because:", - SourceLine(_doc, "expression", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expression`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expression")))) + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12266,10 +19475,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ExpressionTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -12375,7 +19583,7 @@ class WorkflowOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -12387,7 +19595,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12404,7 +19611,7 @@ def __init__( self.format = format self.outputSource = outputSource self.linkMerge = linkMerge - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, WorkflowOutputParameter): @@ -12417,7 +19624,7 @@ def __eq__(self, other: Any) -> bool: and self.format == other.format and self.outputSource == other.outputSource and self.linkMerge == other.linkMerge - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -12432,7 +19639,7 @@ def __hash__(self) -> int: self.format, self.outputSource, self.linkMerge, - self.type, + self.type_, ) ) @@ -12442,9 +19649,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -12453,18 +19661,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -12483,15 +19715,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -12501,15 +19757,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -12519,15 +19799,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -12537,51 +19841,123 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "outputSource" in _doc: try: outputSource = load_field( _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, baseuri, loadingOptions, + lc=_doc.get("outputSource") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputSource' field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputSource`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputSource")))) + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [e], + ) + ) else: outputSource = None if "linkMerge" in _doc: @@ -12591,36 +19967,91 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12634,12 +20065,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'WorkflowOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -12649,7 +20077,7 @@ def fromDoc( format=format, outputSource=outputSource, linkMerge=linkMerge, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -12702,9 +20130,9 @@ def save( r["linkMerge"] = save( self.linkMerge, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -12795,7 +20223,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12847,9 +20274,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepInput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -12858,18 +20286,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -12885,18 +20337,42 @@ def fromDoc( try: source = load_field( _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, baseuri, loadingOptions, + lc=_doc.get("source") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'source' field is not valid because:", - SourceLine(_doc, "source", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("source")))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + ) + ) else: source = None if "linkMerge" in _doc: @@ -12906,15 +20382,39 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None if "loadContents" in _doc: @@ -12924,15 +20424,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -12942,15 +20466,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "label" in _doc: @@ -12960,33 +20508,81 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None if "valueFrom" in _doc: @@ -12996,21 +20592,49 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13024,10 +20648,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepInput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, source=source, @@ -13132,7 +20755,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13157,9 +20779,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepOutput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -13168,18 +20791,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13194,7 +20841,11 @@ def fromDoc( extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13206,10 +20857,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepOutput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, extension_fields=extension_fields, @@ -13319,7 +20969,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13377,9 +21026,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStep": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -13388,18 +21038,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13418,15 +21092,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -13436,47 +21134,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) + in_ = load_field( _doc.get("in"), idmap_in__array_of_WorkflowStepInputLoader, baseuri, loadingOptions, + lc=_doc.get("in") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'in' field is not valid because:", - SourceLine(_doc, "in", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("in")))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + ) + ) try: + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) + out = load_field( _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None, + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("out") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'out' field is not valid because:", - SourceLine(_doc, "out", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `out`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("out")))) + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -13484,15 +21260,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -13502,74 +21302,177 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) try: + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) + run = load_field( _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None, + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None, subscope_baseuri, loadingOptions, + lc=_doc.get("run") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'run' field is not valid because:", - SourceLine(_doc, "run", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `run`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("run")))) + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [e], + ) + ) if "scatter" in _doc: try: scatter = load_field( _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, baseuri, loadingOptions, + lc=_doc.get("scatter") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatter' field is not valid because:", - SourceLine(_doc, "scatter", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatter`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatter")))) + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [e], + ) + ) else: scatter = None if "scatterMethod" in _doc: try: scatterMethod = load_field( _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None, + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("scatterMethod") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatterMethod' field is not valid because:", - SourceLine(_doc, "scatterMethod", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatterMethod`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatterMethod")))) + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [e], + ) + ) else: scatterMethod = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13583,10 +21486,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStep'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -13744,7 +21646,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13802,33 +21703,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Workflow": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Workflow": - raise ValidationException("Not a Workflow") + raise ValidationException("tried `Workflow` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13847,15 +21775,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -13865,47 +21817,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_WorkflowOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -13913,15 +21943,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -13931,54 +21985,133 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None try: + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) + steps = load_field( _doc.get("steps"), idmap_steps_union_of_array_of_WorkflowStepLoader, baseuri, loadingOptions, + lc=_doc.get("steps") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'steps' field is not valid because:", - SourceLine(_doc, "steps", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `steps`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("steps")))) + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13992,10 +22125,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Workflow'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -14099,7 +22231,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14124,21 +22255,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SubworkflowFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SubworkflowFeatureRequirement": - raise ValidationException("Not a SubworkflowFeatureRequirement") + raise ValidationException("tried `SubworkflowFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14150,12 +22288,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'SubworkflowFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14199,7 +22334,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14224,21 +22358,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ScatterFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ScatterFeatureRequirement": - raise ValidationException("Not a ScatterFeatureRequirement") + raise ValidationException("tried `ScatterFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14250,12 +22391,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ScatterFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14299,7 +22437,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14324,21 +22461,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "MultipleInputFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "MultipleInputFeatureRequirement": - raise ValidationException("Not a MultipleInputFeatureRequirement") + raise ValidationException("tried `MultipleInputFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14350,12 +22494,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'MultipleInputFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14399,7 +22540,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14424,21 +22564,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "StepInputExpressionRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "StepInputExpressionRequirement": - raise ValidationException("Not a StepInputExpressionRequirement") + raise ValidationException("tried `StepInputExpressionRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14450,12 +22597,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'StepInputExpressionRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14490,6 +22634,11 @@ def save( _vocab = { "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", + "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", + "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", + "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", + "CWLRecordField": "https://w3id.org/cwl/cwl#CWLRecordField", + "CWLRecordSchema": "https://w3id.org/cwl/cwl#CWLRecordSchema", "CWLType": "https://w3id.org/cwl/cwl#CWLType", "CWLVersion": "https://w3id.org/cwl/cwl#CWLVersion", "CommandInputArraySchema": "https://w3id.org/cwl/cwl#CommandInputArraySchema", @@ -14538,6 +22687,7 @@ def save( "LoadContents": "https://w3id.org/cwl/cwl#LoadContents", "LoadListingEnum": "https://w3id.org/cwl/cwl#LoadListingEnum", "LoadListingRequirement": "https://w3id.org/cwl/cwl#LoadListingRequirement", + "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", "NetworkAccess": "https://w3id.org/cwl/cwl#NetworkAccess", "OutputArraySchema": "https://w3id.org/cwl/cwl#OutputArraySchema", @@ -14565,6 +22715,7 @@ def save( "StepInputExpressionRequirement": "https://w3id.org/cwl/cwl#StepInputExpressionRequirement", "SubworkflowFeatureRequirement": "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement", "ToolTimeLimit": "https://w3id.org/cwl/cwl#ToolTimeLimit", + "UnionSchema": "https://w3id.org/cwl/salad#UnionSchema", "WorkReuse": "https://w3id.org/cwl/cwl#WorkReuse", "Workflow": "https://w3id.org/cwl/cwl#Workflow", "WorkflowInputParameter": "https://w3id.org/cwl/cwl#WorkflowInputParameter", @@ -14592,6 +22743,7 @@ def save( "float": "http://www.w3.org/2001/XMLSchema#float", "int": "http://www.w3.org/2001/XMLSchema#int", "long": "http://www.w3.org/2001/XMLSchema#long", + "map": "https://w3id.org/cwl/salad#map", "merge_flattened": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened", "merge_nested": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested", "nested_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct", @@ -14603,6 +22755,7 @@ def save( "stdin": "https://w3id.org/cwl/cwl#stdin", "stdout": "https://w3id.org/cwl/cwl#stdout", "string": "http://www.w3.org/2001/XMLSchema#string", + "union": "https://w3id.org/cwl/salad#union", "v1.0": "https://w3id.org/cwl/cwl#v1.0", "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", "v1.1": "https://w3id.org/cwl/cwl#v1.1", @@ -14611,6 +22764,11 @@ def save( _rvocab = { "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", + "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", + "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", + "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", + "https://w3id.org/cwl/cwl#CWLRecordField": "CWLRecordField", + "https://w3id.org/cwl/cwl#CWLRecordSchema": "CWLRecordSchema", "https://w3id.org/cwl/cwl#CWLType": "CWLType", "https://w3id.org/cwl/cwl#CWLVersion": "CWLVersion", "https://w3id.org/cwl/cwl#CommandInputArraySchema": "CommandInputArraySchema", @@ -14659,6 +22817,7 @@ def save( "https://w3id.org/cwl/cwl#LoadContents": "LoadContents", "https://w3id.org/cwl/cwl#LoadListingEnum": "LoadListingEnum", "https://w3id.org/cwl/cwl#LoadListingRequirement": "LoadListingRequirement", + "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", "https://w3id.org/cwl/cwl#NetworkAccess": "NetworkAccess", "https://w3id.org/cwl/cwl#OutputArraySchema": "OutputArraySchema", @@ -14686,6 +22845,7 @@ def save( "https://w3id.org/cwl/cwl#StepInputExpressionRequirement": "StepInputExpressionRequirement", "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement": "SubworkflowFeatureRequirement", "https://w3id.org/cwl/cwl#ToolTimeLimit": "ToolTimeLimit", + "https://w3id.org/cwl/salad#UnionSchema": "UnionSchema", "https://w3id.org/cwl/cwl#WorkReuse": "WorkReuse", "https://w3id.org/cwl/cwl#Workflow": "Workflow", "https://w3id.org/cwl/cwl#WorkflowInputParameter": "WorkflowInputParameter", @@ -14713,6 +22873,7 @@ def save( "http://www.w3.org/2001/XMLSchema#float": "float", "http://www.w3.org/2001/XMLSchema#int": "int", "http://www.w3.org/2001/XMLSchema#long": "long", + "https://w3id.org/cwl/salad#map": "map", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened": "merge_flattened", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested": "merge_nested", "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct": "nested_crossproduct", @@ -14724,6 +22885,7 @@ def save( "https://w3id.org/cwl/cwl#stdin": "stdin", "https://w3id.org/cwl/cwl#stdout": "stdout", "http://www.w3.org/2001/XMLSchema#string": "string", + "https://w3id.org/cwl/salad#union": "union", "https://w3id.org/cwl/cwl#v1.0": "v1.0", "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", "https://w3id.org/cwl/cwl#v1.1": "v1.1", @@ -14749,8 +22911,9 @@ def save( "PrimitiveType", ) """ -Salad data types are based on Avro schema declarations. Refer to the -[Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for +Names of salad data types (based on Avro schema declarations). + +Refer to the [Avro schema declaration documentation](https://avro.apache.org/docs/current/spec.html#schemas) for detailed information. null: no value @@ -14765,10 +22928,112 @@ def save( """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField) -RecordSchemaLoader = _RecordLoader(RecordSchema) -EnumSchemaLoader = _RecordLoader(EnumSchema) -ArraySchemaLoader = _RecordLoader(ArraySchema) +RecordFieldLoader = _RecordLoader(RecordField, None, None) +RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) +EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) +ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) +MapSchemaLoader = _RecordLoader(MapSchema, None, None) +UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) +CWLTypeLoader = _EnumLoader( + ( + "null", + "boolean", + "int", + "long", + "float", + "double", + "string", + "File", + "Directory", + ), + "CWLType", +) +""" +Extends primitive types with the concept of a file and directory as a builtin type. +File: A File object +Directory: A Directory object +""" +CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) +CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) +CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) +FileLoader = _RecordLoader(File, None, None) +DirectoryLoader = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) +) +array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( + union_of_None_type_or_CWLObjectTypeLoader +) +map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( + union_of_None_type_or_CWLObjectTypeLoader, "None", None, None +) +InlineJavascriptRequirementLoader = _RecordLoader( + InlineJavascriptRequirement, None, None +) +SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) +LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement, None, None) +DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) +SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) +InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) +EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) +ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) +ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) +WorkReuseLoader = _RecordLoader(WorkReuse, None, None) +NetworkAccessLoader = _RecordLoader(NetworkAccess, None, None) +InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement, None, None) +ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit, None, None) +SubworkflowFeatureRequirementLoader = _RecordLoader( + SubworkflowFeatureRequirement, None, None +) +ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) +MultipleInputFeatureRequirementLoader = _RecordLoader( + MultipleInputFeatureRequirement, None, None +) +StepInputExpressionRequirementLoader = _RecordLoader( + StepInputExpressionRequirement, None, None +) +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( + ( + InlineJavascriptRequirementLoader, + SchemaDefRequirementLoader, + LoadListingRequirementLoader, + DockerRequirementLoader, + SoftwareRequirementLoader, + InitialWorkDirRequirementLoader, + EnvVarRequirementLoader, + ShellCommandRequirementLoader, + ResourceRequirementLoader, + WorkReuseLoader, + NetworkAccessLoader, + InplaceUpdateRequirementLoader, + ToolTimeLimitLoader, + SubworkflowFeatureRequirementLoader, + ScatterFeatureRequirementLoader, + MultipleInputFeatureRequirementLoader, + StepInputExpressionRequirementLoader, + ) +) +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader +) +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader = _UnionLoader( + ( + None_type, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + CWLObjectTypeLoader, + ) +) +map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader = _MapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader, + "CWLInputFile", + "@list", + True, +) +CWLInputFileLoader = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader CWLVersionLoader = _EnumLoader( ( "draft-2", @@ -14791,27 +23056,6 @@ def save( """ Version symbols for published CWL document versions. """ -CWLTypeLoader = _EnumLoader( - ( - "null", - "boolean", - "int", - "long", - "float", - "double", - "string", - "File", - "Directory", - ), - "CWLType", -) -""" -Extends primitive types with the concept of a file and directory as a builtin type. -File: A File object -Directory: A Directory object -""" -FileLoader = _RecordLoader(File) -DirectoryLoader = _RecordLoader(Directory) LoadListingEnumLoader = _EnumLoader( ( "no_listing", @@ -14829,33 +23073,30 @@ def save( deep_listing: Load the directory listing and recursively load all subdirectories as well. """ ExpressionLoader = _ExpressionLoader(str) -InputBindingLoader = _RecordLoader(InputBinding) -InputRecordFieldLoader = _RecordLoader(InputRecordField) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema) -InputArraySchemaLoader = _RecordLoader(InputArraySchema) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema) -InlineJavascriptRequirementLoader = _RecordLoader(InlineJavascriptRequirement) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement) -SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema) -LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding) -CommandLineBindableLoader = _RecordLoader(CommandLineBindable) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter) +InputBindingLoader = _RecordLoader(InputBinding, None, None) +InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) +InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) +InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) +InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) +OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) +OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) +OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) +OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) +SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema, None, None) +EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) +CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) +CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) +CommandLineBindableLoader = _RecordLoader(CommandLineBindable, None, None) +CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) +CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) +CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) +CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) +CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) +CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) +CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) +CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) +CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) +CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) stdinLoader = _EnumLoader(("stdin",), "stdin") """ Only valid as a `type` for a `CommandLineTool` input with no @@ -14966,22 +23207,14 @@ def save( stderr: random_stderr_filenameABCDEFG ``` """ -CommandLineToolLoader = _RecordLoader(CommandLineTool) -DockerRequirementLoader = _RecordLoader(DockerRequirement) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage) -DirentLoader = _RecordLoader(Dirent) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement) -WorkReuseLoader = _RecordLoader(WorkReuse) -NetworkAccessLoader = _RecordLoader(NetworkAccess) -InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement) -ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit) -ExpressionToolOutputParameterLoader = _RecordLoader(ExpressionToolOutputParameter) -WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter) -ExpressionToolLoader = _RecordLoader(ExpressionTool) +CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) +SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) +DirentLoader = _RecordLoader(Dirent, None, None) +ExpressionToolOutputParameterLoader = _RecordLoader( + ExpressionToolOutputParameter, None, None +) +WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter, None, None) +ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) LinkMergeMethodLoader = _EnumLoader( ( "merge_nested", @@ -14992,9 +23225,9 @@ def save( """ The input link merge method, described in [WorkflowStepInput](#WorkflowStepInput). """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput) +WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) +WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) +WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) ScatterMethodLoader = _EnumLoader( ( "dotproduct", @@ -15006,12 +23239,8 @@ def save( """ The scatter method, as described in [workflow step scatter](#WorkflowStep). """ -WorkflowStepLoader = _RecordLoader(WorkflowStep) -WorkflowLoader = _RecordLoader(Workflow) -SubworkflowFeatureRequirementLoader = _RecordLoader(SubworkflowFeatureRequirement) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement) -MultipleInputFeatureRequirementLoader = _RecordLoader(MultipleInputFeatureRequirement) -StepInputExpressionRequirementLoader = _RecordLoader(StepInputExpressionRequirement) +WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) +WorkflowLoader = _RecordLoader(Workflow, None, None) array_of_strtype = _ArrayLoader(strtype) union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( ( @@ -15020,31 +23249,35 @@ def save( array_of_strtype, ) ) -uri_strtype_True_False_None = _URILoader(strtype, True, False, None) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _ArrayLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, - array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, + array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) @@ -15058,35 +23291,85 @@ def save( idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_RecordFieldLoader, "name", "type" ) -enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader = _EnumLoader( - ("record",), "enum_d9cba076fca539106791a4f46d198c7fcfbdb779" +Record_nameLoader = _EnumLoader(("record",), "Record_name") +typedsl_Record_nameLoader_2 = _TypeDSLLoader(Record_nameLoader, 2, "v1.1") +union_of_None_type_or_strtype = _UnionLoader( + ( + None_type, + strtype, + ) +) +uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( + union_of_None_type_or_strtype, True, False, None, None +) +uri_array_of_strtype_True_False_None_None = _URILoader( + array_of_strtype, True, False, None, None +) +Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") +typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, + False, + True, + 2, + None, ) -typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader_2 = _TypeDSLLoader( - enum_d9cba076fca539106791a4f46d198c7fcfbdb779Loader, 2, "v1.1" +Array_nameLoader = _EnumLoader(("array",), "Array_name") +typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") +Map_nameLoader = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") +Union_nameLoader = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + ) ) -uri_array_of_strtype_True_False_None = _URILoader(array_of_strtype, True, False, None) -enum_d961d79c225752b9fadb617367615ab176b47d77Loader = _EnumLoader( - ("enum",), "enum_d961d79c225752b9fadb617367615ab176b47d77" +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype ) -typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77Loader_2 = _TypeDSLLoader( - enum_d961d79c225752b9fadb617367615ab176b47d77Loader, 2, "v1.1" +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + ) ) -enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader = _EnumLoader( - ("array",), "enum_d062602be0b4b8fd33e69e29a841317b6ab665bc" +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + False, + True, + 2, + None, ) -typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader_2 = _TypeDSLLoader( - enum_d062602be0b4b8fd33e69e29a841317b6ab665bcLoader, 2, "v1.1" +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + 2, + "v1.1", ) -File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None = _URILoader(File_classLoader, False, True, None) -union_of_None_type_or_strtype = _UnionLoader( +array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) +union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( ( None_type, - strtype, + array_of_CWLRecordFieldLoader, ) ) -uri_union_of_None_type_or_strtype_False_False_None = _URILoader( - union_of_None_type_or_strtype, False, False, None +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( + union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" +) +File_classLoader = _EnumLoader(("File",), "File_class") +uri_File_classLoader_False_True_None_None = _URILoader( + File_classLoader, False, True, None, None +) +uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( + union_of_None_type_or_strtype, False, False, None, None ) union_of_None_type_or_inttype = _UnionLoader( ( @@ -15109,15 +23392,20 @@ def save( array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _SecondaryDSLLoader( - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader +secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( + ( + _SecondaryDSLLoader( + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader + ), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + ) ) -uri_union_of_None_type_or_strtype_True_False_None = _URILoader( - union_of_None_type_or_strtype, True, False, None +uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( + union_of_None_type_or_strtype, True, False, None, True ) Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None = _URILoader( - Directory_classLoader, False, True, None +uri_Directory_classLoader_False_True_None_None = _URILoader( + Directory_classLoader, False, True, None, None ) union_of_None_type_or_booltype = _UnionLoader( ( @@ -15139,8 +23427,13 @@ def save( array_of_SecondaryFileSchemaLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _SecondaryDSLLoader( - union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader +secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( + ( + _SecondaryDSLLoader( + union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader + ), + union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + ) ) union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -15150,11 +23443,12 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, + True, ) union_of_None_type_or_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -15163,8 +23457,8 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None = _URILoader( - union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( + union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -15203,6 +23497,13 @@ def save( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" ) +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -15240,13 +23541,12 @@ def save( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" ) -union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type = _UnionLoader( - ( - None_type, - FileLoader, - DirectoryLoader, - Any_type, - ) +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, ) union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader = _UnionLoader( ( @@ -15277,30 +23577,6 @@ def save( "id", "type", ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( - ( - InlineJavascriptRequirementLoader, - SchemaDefRequirementLoader, - LoadListingRequirementLoader, - DockerRequirementLoader, - SoftwareRequirementLoader, - InitialWorkDirRequirementLoader, - EnvVarRequirementLoader, - ShellCommandRequirementLoader, - ResourceRequirementLoader, - WorkReuseLoader, - NetworkAccessLoader, - InplaceUpdateRequirementLoader, - ToolTimeLimitLoader, - SubworkflowFeatureRequirementLoader, - ScatterFeatureRequirementLoader, - MultipleInputFeatureRequirementLoader, - StepInputExpressionRequirementLoader, - ) -) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader -) union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( ( None_type, @@ -15354,14 +23630,14 @@ def save( CWLVersionLoader, ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( + union_of_None_type_or_CWLVersionLoader, False, True, None, None ) InlineJavascriptRequirement_classLoader = _EnumLoader( ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" ) -uri_InlineJavascriptRequirement_classLoader_False_True_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None +uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( + InlineJavascriptRequirement_classLoader, False, True, None, None ) union_of_None_type_or_array_of_strtype = _UnionLoader( ( @@ -15372,8 +23648,8 @@ def save( SchemaDefRequirement_classLoader = _EnumLoader( ("SchemaDefRequirement",), "SchemaDefRequirement_class" ) -uri_SchemaDefRequirement_classLoader_False_True_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None +uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( + SchemaDefRequirement_classLoader, False, True, None, None ) union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _UnionLoader( ( @@ -15401,8 +23677,8 @@ def save( LoadListingRequirement_classLoader = _EnumLoader( ("LoadListingRequirement",), "LoadListingRequirement_class" ) -uri_LoadListingRequirement_classLoader_False_True_None = _URILoader( - LoadListingRequirement_classLoader, False, True, None +uri_LoadListingRequirement_classLoader_False_True_None_None = _URILoader( + LoadListingRequirement_classLoader, False, True, None, None ) union_of_None_type_or_inttype_or_ExpressionLoader = _UnionLoader( ( @@ -15470,6 +23746,13 @@ def save( union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) ) +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -15515,6 +23798,13 @@ def save( union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) ) +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( ( CWLTypeLoader, @@ -15549,8 +23839,8 @@ def save( "v1.1", ) CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None = _URILoader( - CommandLineTool_classLoader, False, True, None +uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( + CommandLineTool_classLoader, False, True, None, None ) array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( @@ -15586,27 +23876,27 @@ def save( DockerRequirement_classLoader = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None = _URILoader( - DockerRequirement_classLoader, False, True, None +uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( + DockerRequirement_classLoader, False, True, None, None ) SoftwareRequirement_classLoader = _EnumLoader( ("SoftwareRequirement",), "SoftwareRequirement_class" ) -uri_SoftwareRequirement_classLoader_False_True_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None +uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( + SoftwareRequirement_classLoader, False, True, None, None ) array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( array_of_SoftwarePackageLoader, "package", "specs" ) -uri_union_of_None_type_or_array_of_strtype_False_False_None = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None +uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( + union_of_None_type_or_array_of_strtype, False, False, None, True ) InitialWorkDirRequirement_classLoader = _EnumLoader( ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" ) -uri_InitialWorkDirRequirement_classLoader_False_True_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None +uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( + InitialWorkDirRequirement_classLoader, False, True, None, None ) union_of_None_type_or_FileLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader_or_DirectoryLoader_or_DirentLoader_or_ExpressionLoader = _UnionLoader( ( @@ -15630,8 +23920,8 @@ def save( EnvVarRequirement_classLoader = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None +uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( + EnvVarRequirement_classLoader, False, True, None, None ) array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( @@ -15640,18 +23930,18 @@ def save( ShellCommandRequirement_classLoader = _EnumLoader( ("ShellCommandRequirement",), "ShellCommandRequirement_class" ) -uri_ShellCommandRequirement_classLoader_False_True_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None +uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( + ShellCommandRequirement_classLoader, False, True, None, None ) ResourceRequirement_classLoader = _EnumLoader( ("ResourceRequirement",), "ResourceRequirement_class" ) -uri_ResourceRequirement_classLoader_False_True_None = _URILoader( - ResourceRequirement_classLoader, False, True, None +uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( + ResourceRequirement_classLoader, False, True, None, None ) WorkReuse_classLoader = _EnumLoader(("WorkReuse",), "WorkReuse_class") -uri_WorkReuse_classLoader_False_True_None = _URILoader( - WorkReuse_classLoader, False, True, None +uri_WorkReuse_classLoader_False_True_None_None = _URILoader( + WorkReuse_classLoader, False, True, None, None ) union_of_booltype_or_ExpressionLoader = _UnionLoader( ( @@ -15660,18 +23950,18 @@ def save( ) ) NetworkAccess_classLoader = _EnumLoader(("NetworkAccess",), "NetworkAccess_class") -uri_NetworkAccess_classLoader_False_True_None = _URILoader( - NetworkAccess_classLoader, False, True, None +uri_NetworkAccess_classLoader_False_True_None_None = _URILoader( + NetworkAccess_classLoader, False, True, None, None ) InplaceUpdateRequirement_classLoader = _EnumLoader( ("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class" ) -uri_InplaceUpdateRequirement_classLoader_False_True_None = _URILoader( - InplaceUpdateRequirement_classLoader, False, True, None +uri_InplaceUpdateRequirement_classLoader_False_True_None_None = _URILoader( + InplaceUpdateRequirement_classLoader, False, True, None, None ) ToolTimeLimit_classLoader = _EnumLoader(("ToolTimeLimit",), "ToolTimeLimit_class") -uri_ToolTimeLimit_classLoader_False_True_None = _URILoader( - ToolTimeLimit_classLoader, False, True, None +uri_ToolTimeLimit_classLoader_False_True_None_None = _URILoader( + ToolTimeLimit_classLoader, False, True, None, None ) union_of_inttype_or_ExpressionLoader = _UnionLoader( ( @@ -15686,8 +23976,8 @@ def save( ) ) ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None = _URILoader( - ExpressionTool_classLoader, False, True, None +uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( + ExpressionTool_classLoader, False, True, None, None ) array_of_WorkflowInputParameterLoader = _ArrayLoader(WorkflowInputParameterLoader) idmap_inputs_array_of_WorkflowInputParameterLoader = _IdMapLoader( @@ -15699,8 +23989,8 @@ def save( idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( array_of_ExpressionToolOutputParameterLoader, "id", "type" ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None ) union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( ( @@ -15708,8 +23998,8 @@ def save( LinkMergeMethodLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None ) array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( @@ -15727,13 +24017,12 @@ def save( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) ) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None = ( - _URILoader( - union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, - True, - False, - None, - ) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( + union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, + True, + False, + None, + None, ) array_of_Any_type = _ArrayLoader(Any_type) union_of_None_type_or_array_of_Any_type = _UnionLoader( @@ -15755,14 +24044,15 @@ def save( ) ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None = _URILoader( +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_False_False_None_None = _URILoader( union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader, False, False, None, + None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None ) union_of_None_type_or_ScatterMethodLoader = _UnionLoader( ( @@ -15770,12 +24060,12 @@ def save( ScatterMethodLoader, ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( + union_of_None_type_or_ScatterMethodLoader, False, True, None, None ) Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None = _URILoader( - Workflow_classLoader, False, True, None +uri_Workflow_classLoader_False_True_None_None = _URILoader( + Workflow_classLoader, False, True, None, None ) array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( @@ -15789,26 +24079,26 @@ def save( SubworkflowFeatureRequirement_classLoader = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( + SubworkflowFeatureRequirement_classLoader, False, True, None, None ) ScatterFeatureRequirement_classLoader = _EnumLoader( ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" ) -uri_ScatterFeatureRequirement_classLoader_False_True_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None +uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( + ScatterFeatureRequirement_classLoader, False, True, None, None ) MultipleInputFeatureRequirement_classLoader = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( + MultipleInputFeatureRequirement_classLoader, False, True, None, None ) StepInputExpressionRequirement_classLoader = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None +uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( + StepInputExpressionRequirement_classLoader, False, True, None, None ) union_of_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader = _UnionLoader( ( @@ -15831,6 +24121,19 @@ def save( ) ) +CWLObjectTypeLoader.add_loaders( + ( + booltype, + inttype, + floattype, + strtype, + FileLoader, + DirectoryLoader, + array_of_union_of_None_type_or_CWLObjectTypeLoader, + map_of_union_of_None_type_or_CWLObjectTypeLoader, + ) +) + def load_document( doc: Any, diff --git a/cwl_utils/parser/cwl_v1_1_utils.py b/cwl_utils/parser/cwl_v1_1_utils.py index b19de27a..f942708c 100644 --- a/cwl_utils/parser/cwl_v1_1_utils.py +++ b/cwl_utils/parser/cwl_v1_1_utils.py @@ -1,13 +1,27 @@ # SPDX-License-Identifier: Apache-2.0 import hashlib import logging +import os from collections import namedtuple -from typing import IO, Any, Dict, List, MutableSequence, Optional, Tuple, Union, cast +from io import StringIO +from typing import ( + Any, + Dict, + IO, + List, + MutableMapping, + MutableSequence, + Optional, + Tuple, + Union, + cast, +) +from urllib.parse import urldefrag from ruamel import yaml from schema_salad.exceptions import ValidationException -from schema_salad.sourceline import SourceLine -from schema_salad.utils import aslist, json_dumps +from schema_salad.sourceline import SourceLine, add_lc_filename +from schema_salad.utils import aslist, json_dumps, yaml_no_ts import cwl_utils.parser import cwl_utils.parser.cwl_v1_1 as cwl @@ -30,9 +44,9 @@ def _compare_records( This handles normalizing record names, which will be relative to workflow step, so that they can be compared. """ - srcfields = {cwl.shortname(field.name): field.type for field in (src.fields or {})} + srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} sinkfields = { - cwl.shortname(field.name): field.type for field in (sink.fields or {}) + cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) } for key in sinkfields.keys(): if ( @@ -63,10 +77,10 @@ def _compare_type(type1: Any, type2: Any) -> bool: return _compare_type(type1.items, type2.items) elif isinstance(type1, cwl.RecordSchema) and isinstance(type2, cwl.RecordSchema): fields1 = { - cwl.shortname(field.name): field.type for field in (type1.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type for field in (type2.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -82,6 +96,64 @@ def _compare_type(type1: Any, type2: Any) -> bool: return bool(type1 == type2) +def _inputfile_load( + doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + baseuri: str, + loadingOptions: cwl.LoadingOptions, + addl_metadata_fields: Optional[MutableSequence[str]] = None, +) -> Tuple[Any, cwl.LoadingOptions]: + loader = cwl.CWLInputFileLoader + if isinstance(doc, str): + url = loadingOptions.fetcher.urljoin(baseuri, doc) + if url in loadingOptions.idx: + return loadingOptions.idx[url] + doc_url, frg = urldefrag(url) + text = loadingOptions.fetcher.fetch_text(doc_url) + textIO = StringIO(text) + textIO.name = str(doc_url) + yaml = yaml_no_ts() + result = yaml.load(textIO) + add_lc_filename(result, doc_url) + loadingOptions = cwl.LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) + _inputfile_load( + result, + doc_url, + loadingOptions, + ) + return loadingOptions.idx[url] + + if isinstance(doc, MutableMapping): + addl_metadata = {} + if addl_metadata_fields is not None: + for mf in addl_metadata_fields: + if mf in doc: + addl_metadata[mf] = doc[mf] + + loadingOptions = cwl.LoadingOptions( + copyfrom=loadingOptions, + baseuri=baseuri, + addl_metadata=addl_metadata, + ) + + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions, docRoot=baseuri), + loadingOptions, + ) + + return loadingOptions.idx[baseuri] + + if isinstance(doc, MutableSequence): + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions), + loadingOptions, + ) + return loadingOptions.idx[baseuri] + + raise ValidationException( + "Expected URI string, MutableMapping or MutableSequence, got %s" % type(doc) + ) + + def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: """ Check for identical type specifications, ignoring extra keys like inputBinding. @@ -184,7 +256,7 @@ def check_types( return "exception" if linkMerge == "merge_nested": return check_types( - cwl.ArraySchema(items=srctype, type="array"), sinktype, None, None + cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None ) if linkMerge == "merge_flattened": return check_types(merge_flatten_type(srctype), sinktype, None, None) @@ -212,7 +284,7 @@ def content_limit_respected_read(f: IO[bytes]) -> str: def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: """Convert stdin, stdout and stderr type shortcuts to files.""" for out in clt.outputs: - if out.type == "stdout": + if out.type_ == "stdout": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stdout shortcut." @@ -223,9 +295,9 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stdout) - elif out.type == "stderr": + elif out.type_ == "stderr": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stderr shortcut." @@ -236,10 +308,10 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stderr) for inp in clt.inputs: - if inp.type == "stdin": + if inp.type_ == "stdin": if inp.inputBinding is not None: raise ValidationException( "Not allowed to specify unputBinding when using stdin shortcut." @@ -253,7 +325,66 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: "$(inputs.%s.path)" % cast(str, inp.id).rpartition("#")[2].split("/")[-1] ) - inp.type = "File" + inp.type_ = "File" + + +def load_inputfile( + doc: Any, + baseuri: Optional[str] = None, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.1 input file from a serialized YAML string or a YAML object.""" + if baseuri is None: + baseuri = cwl.file_uri(os.getcwd()) + "/" + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions() + + result, metadata = _inputfile_load( + doc, + baseuri, + loadingOptions, + ) + return result + + +def load_inputfile_by_string( + string: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.1 input file from a serialized YAML string.""" + yaml = yaml_no_ts() + result = yaml.load(string) + add_lc_filename(result, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + result, + uri, + loadingOptions, + ) + return result + + +def load_inputfile_by_yaml( + yaml: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.1 input file from a YAML object.""" + add_lc_filename(yaml, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + yaml, + uri, + loadingOptions, + ) + return result def merge_flatten_type(src: Any) -> Any: @@ -262,7 +393,7 @@ def merge_flatten_type(src: Any) -> Any: return [merge_flatten_type(t) for t in src] if isinstance(src, cwl.ArraySchema): return src - return cwl.ArraySchema(type="array", items=src) + return cwl.ArraySchema(type_="array", items=src) def type_for_step_input( @@ -280,9 +411,9 @@ def type_for_step_input( cast(str, step_input.id).split("#")[-1] == cast(str, in_.id).split("#")[-1] ): - input_type = step_input.type + input_type = step_input.type_ if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type="array") + input_type = cwl.ArraySchema(items=input_type, type_="array") return input_type return "Any" @@ -300,15 +431,15 @@ def type_for_step_output( output.id.split("#")[-1].split("/")[-1] == sourcename.split("#")[-1].split("/")[-1] ): - output_type = output.type + output_type = output.type_ if step.scatter is not None: if step.scatterMethod == "nested_crossproduct": for _ in range(len(aslist(step.scatter))): output_type = cwl.ArraySchema( - items=output_type, type="array" + items=output_type, type_="array" ) else: - output_type = cwl.ArraySchema(items=output_type, type="array") + output_type = cwl.ArraySchema(items=output_type, type_="array") return output_type raise ValidationException( "param {} not found in {}.".format( @@ -328,15 +459,15 @@ def type_for_source( scatter_context: List[Optional[Tuple[int, str]]] = [] params = param_for_source_id(process, sourcenames, parent, scatter_context) if not isinstance(params, list): - new_type = params.type + new_type = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") else: - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": new_type = merge_flatten_type(new_type) return new_type @@ -344,26 +475,28 @@ def type_for_source( for p, sc in zip(params, scatter_context): if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): cur_type = p - elif hasattr(p, "type") and not any(_compare_type(t, p.type) for t in new_type): - cur_type = p.type + elif hasattr(p, "type_") and not any( + _compare_type(t, p.type_) for t in new_type + ): + cur_type = p.type_ else: cur_type = None if cur_type is not None: if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") else: - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") new_type.append(cur_type) if len(new_type) == 1: new_type = new_type[0] if linkMerge == "merge_nested": - return cwl.ArraySchema(items=new_type, type="array") + return cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": return merge_flatten_type(new_type) elif isinstance(sourcenames, List) and len(sourcenames) > 1: - return cwl.ArraySchema(items=new_type, type="array") + return cwl.ArraySchema(items=new_type, type_="array") else: return new_type diff --git a/cwl_utils/parser/cwl_v1_2.py b/cwl_utils/parser/cwl_v1_2.py index cb3aed94..fea42807 100644 --- a/cwl_utils/parser/cwl_v1_2.py +++ b/cwl_utils/parser/cwl_v1_2.py @@ -11,6 +11,7 @@ import xml.sax # nosec from abc import ABC, abstractmethod from io import StringIO +from itertools import chain from typing import ( Any, Dict, @@ -59,6 +60,8 @@ class LoadingOptions: cache: CacheType imports: List[str] includes: List[str] + no_link_check: Optional[bool] + container: Optional[str] def __init__( self, @@ -73,6 +76,8 @@ def __init__( idx: Optional[IdxType] = None, imports: Optional[List[str]] = None, includes: Optional[List[str]] = None, + no_link_check: Optional[bool] = None, + container: Optional[str] = None, ) -> None: """Create a LoadingOptions object.""" self.original_doc = original_doc @@ -117,6 +122,16 @@ def __init__( else: self.includes = copyfrom.includes if copyfrom is not None else [] + if no_link_check is not None: + self.no_link_check = no_link_check + else: + self.no_link_check = copyfrom.no_link_check if copyfrom is not None else False + + if container is not None: + self.container = container + else: + self.container = copyfrom.container if copyfrom is not None else None + if fetcher is not None: self.fetcher = fetcher elif copyfrom is not None: @@ -138,10 +153,10 @@ def __init__( self.vocab = _vocab self.rvocab = _rvocab - if namespaces is not None: + if self.namespaces is not None: self.vocab = self.vocab.copy() self.rvocab = self.rvocab.copy() - for k, v in namespaces.items(): + for k, v in self.namespaces.items(): self.vocab[k] = v self.rvocab[v] = k @@ -204,8 +219,14 @@ def save( """Convert this object to a JSON/YAML friendly dictionary.""" -def load_field(val, fieldtype, baseuri, loadingOptions): - # type: (Union[str, Dict[str, str]], _Loader, str, LoadingOptions) -> Any +def load_field( + val: Union[str, Dict[str, str]], + fieldtype: "_Loader", + baseuri: str, + loadingOptions: LoadingOptions, + lc: Optional[List[Any]] = None, +) -> Any: + """Load field.""" if isinstance(val, MutableMapping): if "$import" in val: if loadingOptions.fileuri is None: @@ -224,12 +245,69 @@ def load_field(val, fieldtype, baseuri, loadingOptions): url = loadingOptions.fetcher.urljoin(loadingOptions.fileuri, val["$include"]) val = loadingOptions.fetcher.fetch_text(url) loadingOptions.includes.append(url) - return fieldtype.load(val, baseuri, loadingOptions) + return fieldtype.load(val, baseuri, loadingOptions, lc=lc) save_type = Optional[Union[MutableMapping[str, Any], MutableSequence[Any], int, float, bool, str]] +def extract_type(val_type: Type[Any]) -> str: + """Take a type of value, and extracts the value as a string.""" + val_str = str(val_type) + return val_str.split("'")[1] + + +def convert_typing(val_type: str) -> str: + """Normalize type names to schema-salad types.""" + if "None" in val_type: + return "null" + if "CommentedSeq" in val_type or "list" in val_type: + return "array" + if "CommentedMap" in val_type or "dict" in val_type: + return "object" + if "False" in val_type or "True" in val_type: + return "boolean" + return val_type + + +def parse_errors(error_message: str) -> Tuple[str, str, str]: + """Parse error messages from several loaders into one error message.""" + if not error_message.startswith("Expected"): + return error_message, "", "" + vals = error_message.split("\n") + if len(vals) == 1: + return error_message, "", "" + types = set() + for val in vals: + individual_vals = val.split(" ") + if val == "": + continue + if individual_vals[1] == "one": + individual_vals = val.split("(")[1].split(",") + for t in individual_vals: + types.add(t.strip(" ").strip(")\n")) + elif individual_vals[2] == "").replace("'", "")) + elif individual_vals[0] == "Value": + types.add(individual_vals[-1].strip(".")) + else: + types.add(individual_vals[1].replace(",", "")) + types = set(val for val in types if val != "NoneType") + if "str" in types: + types = set(convert_typing(val) for val in types if "'" not in val) + to_print = "" + for val in types: + if "'" in val: + to_print = "value" if len(types) == 1 else "values" + + if to_print == "": + to_print = "type" if len(types) == 1 else "types" + + verb_tensage = "is" if len(types) == 1 else "are" + + return str(types).replace("{", "(").replace("}", ")").replace("'", ""), to_print, verb_tensage + + def save( val: Any, top: bool = True, @@ -279,14 +357,13 @@ def save_with_metadata( def expand_url( - url, # type: str - base_url, # type: str - loadingOptions, # type: LoadingOptions - scoped_id=False, # type: bool - vocab_term=False, # type: bool - scoped_ref=None, # type: Optional[int] -): - # type: (...) -> str + url: str, + base_url: str, + loadingOptions: LoadingOptions, + scoped_id: bool = False, + vocab_term: bool = False, + scoped_ref: Optional[int] = None, +) -> str: if url in ("@id", "@type"): return url @@ -347,88 +424,186 @@ def expand_url( class _Loader: - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: pass class _AnyLoader(_Loader): - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc is not None: return doc raise ValidationException("Expected non-null") class _PrimitiveLoader(_Loader): - def __init__(self, tp): - # type: (Union[type, Tuple[Type[str], Type[str]]]) -> None + def __init__(self, tp: Union[type, Tuple[Type[str], Type[str]]]) -> None: self.tp = tp - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, self.tp): raise ValidationException( - "Expected a {} but got {}".format( - self.tp.__class__.__name__, doc.__class__.__name__ - ) + "Expected a {} but got {}".format(self.tp, doc.__class__.__name__) ) return doc - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.tp) class _ArrayLoader(_Loader): - def __init__(self, items): - # type: (_Loader) -> None + def __init__(self, items: _Loader) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableSequence): - raise ValidationException(f"Expected a list, was {type(doc)}") - r = [] # type: List[Any] - errors = [] # type: List[SchemaSaladException] + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an array." + ) + r: List[Any] = [] + errors: List[SchemaSaladException] = [] + fields: List[str] = [] for i in range(0, len(doc)): try: - lf = load_field(doc[i], _UnionLoader((self, self.items)), baseuri, loadingOptions) - if isinstance(lf, MutableSequence): + lf = load_field( + doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc + ) + flatten = loadingOptions.container != "@list" + if flatten and isinstance(lf, MutableSequence): r.extend(lf) else: r.append(lf) + + if isinstance(doc[i], CommentedMap): + if doc[i].get("id") is not None: + if doc[i].get("id") in fields: + errors.append( + ValidationException( + f"Duplicate field {doc[i].get('id')!r}", + SourceLine(doc[i], "id", str), + [], + ) + ) + else: + fields.append(doc[i].get("id")) + except ValidationException as e: - errors.append(e.with_sourceline(SourceLine(doc, i, str))) + e = ValidationException( + "array item is invalid because", SourceLine(doc, i, str), [e] + ) + errors.append(e) if errors: raise ValidationException("", None, errors) return r - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return f"array<{self.items}>" +class _MapLoader(_Loader): + def __init__( + self, + values: _Loader, + name: Optional[str] = None, + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: + self.values = values + self.name = name + self.container = container + self.no_link_check = no_link_check + + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if not isinstance(doc, MutableMapping): + raise ValidationException(f"Expected a map, was {type(doc)}") + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) + r: Dict[str, Any] = {} + errors: List[SchemaSaladException] = [] + for k, v in doc.items(): + try: + lf = load_field(v, self.values, baseuri, loadingOptions, lc) + r[k] = lf + except ValidationException as e: + errors.append(e.with_sourceline(SourceLine(doc, k, str))) + if errors: + raise ValidationException("", None, errors) + return r + + def __repr__(self) -> str: + return self.name if self.name is not None else f"map" + + class _EnumLoader(_Loader): def __init__(self, symbols: Sequence[str], name: str) -> None: self.symbols = symbols self.name = name - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if doc in self.symbols: return doc raise ValidationException(f"Expected one of {self.symbols}") - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return self.name class _SecondaryDSLLoader(_Loader): - def __init__(self, inner): - # type: (_Loader) -> None + def __init__(self, inner: _Loader) -> None: self.inner = inner - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: r: List[Dict[str, Any]] = [] if isinstance(doc, MutableSequence): for d in doc: @@ -486,21 +661,40 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): r.append({"pattern": doc}) else: raise ValidationException("Expected str or sequence of str") - return self.inner.load(r, baseuri, loadingOptions, docRoot) + return self.inner.load(r, baseuri, loadingOptions, docRoot, lc=lc) class _RecordLoader(_Loader): - def __init__(self, classtype): - # type: (Type[Saveable]) -> None + def __init__( + self, + classtype: Type[Saveable], + container: Optional[str] = None, + no_link_check: Optional[bool] = None, + ) -> None: self.classtype = classtype + self.container = container + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, MutableMapping): - raise ValidationException(f"Expected a dict, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is an object." + ) + if self.container is not None or self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, container=self.container, no_link_check=self.no_link_check + ) return self.classtype.fromDoc(doc, baseuri, loadingOptions, docRoot=docRoot) - def __repr__(self): # type: () -> str + def __repr__(self) -> str: return str(self.classtype.__name__) @@ -508,41 +702,139 @@ class _ExpressionLoader(_Loader): def __init__(self, items: Type[str]) -> None: self.items = items - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if not isinstance(doc, str): - raise ValidationException(f"Expected a str, was {type(doc)}") + raise ValidationException( + f"Value is a {convert_typing(extract_type(type(doc)))}, " + f"but valid type for this field is a str." + ) return doc class _UnionLoader(_Loader): - def __init__(self, alternates: Sequence[_Loader]) -> None: + def __init__(self, alternates: Sequence[_Loader], name: Optional[str] = None) -> None: self.alternates = alternates + self.name = name - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def add_loaders(self, loaders: Sequence[_Loader]) -> None: + self.alternates = tuple(loader for loader in chain(self.alternates, loaders)) + + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: errors = [] + + if lc is None: + lc = [] + for t in self.alternates: try: - return t.load(doc, baseuri, loadingOptions, docRoot=docRoot) + return t.load(doc, baseuri, loadingOptions, docRoot=docRoot, lc=lc) except ValidationException as e: - errors.append(ValidationException(f"tried {t} but", None, [e])) - raise ValidationException("", None, errors, "-") + if isinstance(t, _ArrayLoader) and len(self.alternates) > 1: + continue + if isinstance(doc, (CommentedMap, dict)): + if "class" in doc: + if str(doc.get("class")) == str(t): + errors.append( + ValidationException( + f"Object `{baseuri.split('/')[-1]}` is not valid because:", + SourceLine(doc, next(iter(doc)), str), + [e], + ) + ) + else: + if "array" in str(t): + continue + else: + if "id" in doc: + id = baseuri.split("/")[-1] + "#" + str(doc.get("id")) + if "id" in lc: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, "id", str), + [e], + ) + ) + else: + errors.append( + ValidationException( + f"checking object `{id}`", + SourceLine(lc, doc.get("id"), str), + [e], + ) + ) + else: + if not isinstance( + t, (_PrimitiveLoader) + ): # avoids 'tried was {x}' errors + errors.append( + ValidationException(f"tried `{t}` but", None, [e]) + ) + else: + # avoids "tried but x" and instead returns the values for parsing + errors.append(ValidationException("", None, [e])) - def __repr__(self): # type: () -> str - return " | ".join(str(a) for a in self.alternates) + if isinstance(doc, (CommentedMap, dict)) and "class" in doc: + if str(doc.get("class")) not in str(self.alternates): + errors.append( + ValidationException( + "Field `class` contains undefined reference to " + + "`" + + "/".join(baseuri.split("/")[0:-1]) + + "/" + + str(doc.get("class")) + + "`", + SourceLine(doc, "class", str), + [], + ) + ) + raise ValidationException("", None, errors, "*") + + def __repr__(self) -> str: + return self.name if self.name is not None else " | ".join(str(a) for a in self.alternates) class _URILoader(_Loader): - def __init__(self, inner, scoped_id, vocab_term, scoped_ref): - # type: (_Loader, bool, bool, Union[int, None]) -> None + def __init__( + self, + inner: _Loader, + scoped_id: bool, + vocab_term: bool, + scoped_ref: Optional[int], + no_link_check: Optional[bool], + ) -> None: self.inner = inner self.scoped_id = scoped_id self.vocab_term = vocab_term self.scoped_ref = scoped_ref + self.no_link_check = no_link_check - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: + if self.no_link_check is not None: + loadingOptions = LoadingOptions( + copyfrom=loadingOptions, no_link_check=self.no_link_check + ) if isinstance(doc, MutableSequence): newdoc = [] for i in doc: @@ -569,23 +861,33 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): self.vocab_term, self.scoped_ref, ) - return self.inner.load(doc, baseuri, loadingOptions) + if isinstance(doc, str): + if not loadingOptions.no_link_check: + errors = [] + try: + if not loadingOptions.fetcher.check_exists(doc): + errors.append( + ValidationException(f"contains undefined reference to `{doc}`") + ) + except ValidationException: + pass + if len(errors) > 0: + raise ValidationException("", None, errors) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _TypeDSLLoader(_Loader): - def __init__(self, inner, refScope, salad_version): - # type: (_Loader, Union[int, None], str) -> None + def __init__(self, inner: _Loader, refScope: Optional[int], salad_version: str) -> None: self.inner = inner self.refScope = refScope self.salad_version = salad_version def resolve( self, - doc, # type: str - baseuri, # type: str - loadingOptions, # type: LoadingOptions - ): - # type: (...) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + doc: str, + baseuri: str, + loadingOptions: LoadingOptions, + ) -> Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str]: doc_ = doc optional = False if doc_.endswith("?"): @@ -594,7 +896,7 @@ def resolve( if doc_.endswith("[]"): salad_versions = [int(v) for v in self.salad_version[1:].split(".")] - items = "" # type: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] + items: Union[List[Union[Dict[str, Any], str]], Dict[str, Any], str] = "" rest = doc_[0:-2] if salad_versions < [1, 3]: if rest.endswith("[]"): @@ -606,7 +908,7 @@ def resolve( items = self.resolve(rest, baseuri, loadingOptions) if isinstance(items, str): items = expand_url(items, baseuri, loadingOptions, False, True, self.refScope) - expanded = {"type": "array", "items": items} # type: Union[Dict[str, Any], str] + expanded: Union[Dict[str, Any], str] = {"type": "array", "items": items} else: expanded = expand_url(doc_, baseuri, loadingOptions, False, True, self.refScope) @@ -615,10 +917,16 @@ def resolve( else: return expanded - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableSequence): - r = [] # type: List[Any] + r: List[Any] = [] for d in doc: if isinstance(d, str): resolved = self.resolve(d, baseuri, loadingOptions) @@ -635,20 +943,25 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): elif isinstance(doc, str): doc = self.resolve(doc, baseuri, loadingOptions) - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) class _IdMapLoader(_Loader): - def __init__(self, inner, mapSubject, mapPredicate): - # type: (_Loader, str, Union[str, None]) -> None + def __init__(self, inner: _Loader, mapSubject: str, mapPredicate: Optional[str]) -> None: self.inner = inner self.mapSubject = mapSubject self.mapPredicate = mapPredicate - def load(self, doc, baseuri, loadingOptions, docRoot=None): - # type: (Any, str, LoadingOptions, Optional[str]) -> Any + def load( + self, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None, + lc: Optional[List[Any]] = None, + ) -> Any: if isinstance(doc, MutableMapping): - r = [] # type: List[Any] + r: List[Any] = [] for k in sorted(doc.keys()): val = doc[k] if isinstance(val, CommentedMap): @@ -669,7 +982,7 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None): else: raise ValidationException("No mapPredicate") doc = r - return self.inner.load(doc, baseuri, loadingOptions) + return self.inner.load(doc, baseuri, loadingOptions, lc=lc) def _document_load( @@ -706,7 +1019,13 @@ def _document_load( addl_metadata=addl_metadata, ) - doc = {k: v for k, v in doc.items() if k not in ("$namespaces", "$schemas", "$base")} + doc = copy.copy(doc) + if "$namespaces" in doc: + doc.pop("$namespaces") + if "$schemas" in doc: + doc.pop("$schemas") + if "$base" in doc: + doc.pop("$base") if "$graph" in doc: loadingOptions.idx[baseuri] = ( @@ -767,7 +1086,8 @@ def _document_load_by_url( return loadingOptions.idx[url] -def file_uri(path, split_frag=False): # type: (str, bool) -> str +def file_uri(path: str, split_frag: bool = False) -> str: + """Transform a file path into a URL with file scheme.""" if path.startswith("file://"): return path if split_frag: @@ -857,12 +1177,11 @@ class RecordField(Documented): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -873,19 +1192,19 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordField): return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.doc, self.name, self.type)) + return hash((self.doc, self.name, self.type_)) @classmethod def fromDoc( @@ -893,9 +1212,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -904,18 +1224,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -924,7 +1268,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -934,36 +1278,91 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2, + typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -977,14 +1376,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1009,9 +1407,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1028,12 +1426,11 @@ def save( class RecordSchema(Saveable): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1043,15 +1440,15 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, RecordSchema): - return bool(self.fields == other.fields and self.type == other.type) + return bool(self.fields == other.fields and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.fields, self.type)) + return hash((self.fields, self.type_)) @classmethod def fromDoc( @@ -1059,9 +1456,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "RecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -1073,36 +1471,91 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_RecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1116,13 +1569,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'RecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1143,9 +1595,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1168,12 +1620,11 @@ class EnumSchema(Saveable): def __init__( self, symbols: Any, - type: Any, + type_: Any, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1184,19 +1635,19 @@ def __init__( self.loadingOptions = LoadingOptions() self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, EnumSchema): return bool( self.name == other.name and self.symbols == other.symbols - and self.type == other.type + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type)) + return hash((self.name, self.symbols, self.type_)) @classmethod def fromDoc( @@ -1204,9 +1655,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -1215,18 +1667,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -1239,39 +1715,1094 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], - ) + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + symbols=symbols, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[name] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.symbols is not None: + u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) + r["symbols"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["name", "symbols", "type"]) + + +class ArraySchema(Saveable): + def __init__( + self, + items: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, ArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "ArraySchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class MapSchema(Saveable): + def __init__( + self, + type_: Any, + values: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.type_ = type_ + self.values = values + + def __eq__(self, other: Any) -> bool: + if isinstance(other, MapSchema): + return bool(self.type_ == other.type_ and self.values == other.values) + return False + + def __hash__(self) -> int: + return hash((self.type_, self.values)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "MapSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Map_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + try: + if _doc.get("values") is None: + raise ValidationException("missing required field `values`", None, []) + + values = load_field( + _doc.get("values"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("values") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `values`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("values")))) + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `values` field is not valid because:", + SourceLine(_doc, "values", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `type`, `values`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + type_=type_, + values=values, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.values is not None: + u = save_relative_uri(self.values, base_url, False, 2, relative_uris) + r["values"] = u + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["type", "values"]) + + +class UnionSchema(Saveable): + def __init__( + self, + names: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.names = names + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, UnionSchema): + return bool(self.names == other.names and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.names, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "UnionSchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("names") is None: + raise ValidationException("missing required field `names`", None, []) + + names = load_field( + _doc.get("names"), + uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("names") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `names`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("names")))) + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `names` field is not valid because:", + SourceLine(_doc, "names", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Union_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `names`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + names=names, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.names is not None: + u = save_relative_uri(self.names, base_url, False, 2, relative_uris) + r["names"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["names", "type"]) + + +class CWLArraySchema(ArraySchema): + def __init__( + self, + items: Any, + type_: Any, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.items = items + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLArraySchema): + return bool(self.items == other.items and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.items, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLArraySchema": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + + items = load_field( + _doc.get("items"), + uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None, + baseuri, + loadingOptions, + lc=_doc.get("items") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_Array_nameLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) + extension_fields: Dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `items`, `type`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + items=items, + type_=type_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> Dict[str, Any]: + r: Dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.items is not None: + u = save_relative_uri(self.items, base_url, False, 2, relative_uris) + r["items"] = u + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["items", "type"]) + + +class CWLRecordField(RecordField): + def __init__( + self, + name: Any, + type_: Any, + doc: Optional[Any] = None, + extension_fields: Optional[Dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.doc = doc + self.name = name + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, CWLRecordField): + return bool( + self.doc == other.doc + and self.name == other.name + and self.type_ == other.type_ + ) + return False + + def __hash__(self) -> int: + return hash((self.doc, self.name, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "CWLRecordField": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) + else: + name = None + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + _errors__.append(ValidationException("missing name")) + if not __original_name_is_none: + baseuri = name + if "doc" in _doc: + try: + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) + else: + doc = None + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1279,20 +2810,19 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `symbols`, `type`".format( + "invalid field `{}`, expected one of: `doc`, `name`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( + doc=doc, name=name, - symbols=symbols, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1313,12 +2843,13 @@ def save( if self.name is not None: u = save_relative_uri(self.name, base_url, True, None, relative_uris) r["name"] = u - if self.symbols is not None: - u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) - r["symbols"] = u - if self.type is not None: + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -1329,18 +2860,17 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["name", "symbols", "type"]) + attrs = frozenset(["doc", "name", "type"]) -class ArraySchema(Saveable): +class CWLRecordSchema(RecordSchema): def __init__( self, - items: Any, - type: Any, + type_: Any, + fields: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1349,16 +2879,16 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.items = items - self.type = type + self.fields = fields + self.type_ = type_ def __eq__(self, other: Any) -> bool: - if isinstance(other, ArraySchema): - return bool(self.items == other.items and self.type == other.type) + if isinstance(other, CWLRecordSchema): + return bool(self.fields == other.fields and self.type_ == other.type_) return False def __hash__(self) -> int: - return hash((self.items, self.type)) + return hash((self.fields, self.type_)) @classmethod def fromDoc( @@ -1366,47 +2896,106 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, - ) -> "ArraySchema": + docRoot: Optional[str] = None + ) -> "CWLRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - items = load_field( - _doc.get("items"), - uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_False_True_2, - baseuri, - loadingOptions, - ) - except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + if "fields" in _doc: + try: + fields = load_field( + _doc.get("fields"), + idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader, + baseuri, + loadingOptions, + lc=_doc.get("fields") ) - ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) + else: + fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), - typedsl_Array_nameLoader_2, + typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1414,19 +3003,18 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `items`, `type`".format( + "invalid field `{}`, expected one of: `fields`, `type`".format( k ), SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( - items=items, - type=type, + fields=fields, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -1443,12 +3031,13 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.items is not None: - u = save_relative_uri(self.items, base_url, False, 2, relative_uris) - r["items"] = u - if self.type is not None: + if self.fields is not None: + r["fields"] = save( + self.fields, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -1459,7 +3048,7 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["items", "type"]) + attrs = frozenset(["fields", "type"]) class File(Saveable): @@ -1549,7 +3138,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -1613,51 +3201,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "File": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "File": - raise ValidationException("Not a File") + raise ValidationException("tried `File` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -1667,15 +3306,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "dirname" in _doc: @@ -1685,15 +3348,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dirname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dirname' field is not valid because:", - SourceLine(_doc, "dirname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dirname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dirname")))) + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dirname` field is not valid because:", + SourceLine(_doc, "dirname", str), + [e], + ) + ) else: dirname = None if "nameroot" in _doc: @@ -1703,15 +3390,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameroot") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameroot' field is not valid because:", - SourceLine(_doc, "nameroot", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameroot`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameroot")))) + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameroot` field is not valid because:", + SourceLine(_doc, "nameroot", str), + [e], + ) + ) else: nameroot = None if "nameext" in _doc: @@ -1721,15 +3432,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("nameext") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'nameext' field is not valid because:", - SourceLine(_doc, "nameext", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `nameext`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("nameext")))) + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `nameext` field is not valid because:", + SourceLine(_doc, "nameext", str), + [e], + ) + ) else: nameext = None if "checksum" in _doc: @@ -1739,15 +3474,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("checksum") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'checksum' field is not valid because:", - SourceLine(_doc, "checksum", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `checksum`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("checksum")))) + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `checksum` field is not valid because:", + SourceLine(_doc, "checksum", str), + [e], + ) + ) else: checksum = None if "size" in _doc: @@ -1757,15 +3516,39 @@ def fromDoc( union_of_None_type_or_inttype, baseuri, loadingOptions, + lc=_doc.get("size") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'size' field is not valid because:", - SourceLine(_doc, "size", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("size")))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + ) + ) else: size = None if "secondaryFiles" in _doc: @@ -1775,33 +3558,81 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "contents" in _doc: @@ -1811,21 +3642,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("contents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'contents' field is not valid because:", - SourceLine(_doc, "contents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `contents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("contents")))) + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `contents` field is not valid because:", + SourceLine(_doc, "contents", str), + [e], + ) + ) else: contents = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -1839,10 +3698,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'File'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -2001,7 +3859,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2038,51 +3895,102 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Directory": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Directory": - raise ValidationException("Not a Directory") + raise ValidationException("tried `Directory` but") if "location" in _doc: try: location = load_field( _doc.get("location"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("location") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'location' field is not valid because:", - SourceLine(_doc, "location", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `location`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("location")))) + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `location` field is not valid because:", + SourceLine(_doc, "location", str), + [e], + ) + ) else: location = None if "path" in _doc: try: path = load_field( _doc.get("path"), - uri_union_of_None_type_or_strtype_False_False_None, + uri_union_of_None_type_or_strtype_False_False_None_None, baseuri, loadingOptions, + lc=_doc.get("path") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'path' field is not valid because:", - SourceLine(_doc, "path", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `path`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("path")))) + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `path` field is not valid because:", + SourceLine(_doc, "path", str), + [e], + ) + ) else: path = None if "basename" in _doc: @@ -2092,15 +4000,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("basename") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'basename' field is not valid because:", - SourceLine(_doc, "basename", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `basename`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("basename")))) + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `basename` field is not valid because:", + SourceLine(_doc, "basename", str), + [e], + ) + ) else: basename = None if "listing" in _doc: @@ -2110,21 +4042,49 @@ def fromDoc( union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) else: listing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2138,10 +4098,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Directory'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( location=location, path=path, @@ -2231,7 +4190,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2256,9 +4214,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2270,21 +4229,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2298,10 +4285,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, extension_fields=extension_fields, @@ -2351,11 +4337,11 @@ class OutputSchema(IOSchema): pass -class InputRecordField(RecordField, FieldBase, InputFormat, LoadContents): +class InputRecordField(CWLRecordField, FieldBase, InputFormat, LoadContents): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -2366,7 +4352,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2377,7 +4362,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -2390,7 +4375,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -2405,7 +4390,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -2421,9 +4406,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2432,18 +4418,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2452,7 +4462,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -2462,32 +4472,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2495,15 +4556,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -2513,15 +4598,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -2531,33 +4640,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -2567,15 +4724,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -2585,21 +4766,49 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2613,14 +4822,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -2651,9 +4859,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2714,10 +4922,10 @@ def save( ) -class InputRecordSchema(RecordSchema, InputSchema): +class InputRecordSchema(CWLRecordSchema, InputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -2725,7 +4933,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2735,7 +4942,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -2744,7 +4951,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -2752,7 +4959,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -2760,9 +4967,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2771,18 +4979,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -2801,32 +5033,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -2834,15 +5117,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -2852,21 +5159,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -2880,13 +5215,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -2914,9 +5248,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -2942,14 +5276,13 @@ class InputEnumSchema(EnumSchema, InputSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -2960,7 +5293,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc @@ -2969,14 +5302,14 @@ def __eq__(self, other: Any) -> bool: return bool( self.name == other.name and self.symbols == other.symbols - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type, self.label, self.doc)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -2984,9 +5317,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -2995,18 +5329,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3019,35 +5377,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3055,15 +5467,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3073,21 +5509,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3101,14 +5565,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, extension_fields=extension_fields, @@ -3134,9 +5597,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3158,18 +5621,17 @@ def save( attrs = frozenset(["name", "symbols", "type", "label", "doc"]) -class InputArraySchema(ArraySchema, InputSchema): +class InputArraySchema(CWLArraySchema, InputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3179,7 +5641,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -3188,7 +5650,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, InputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -3196,7 +5658,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -3204,9 +5666,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3215,18 +5678,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3239,35 +5726,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2, + uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3275,15 +5816,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3293,21 +5858,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3321,13 +5914,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'InputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -3354,9 +5946,9 @@ def save( if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) r["items"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3378,11 +5970,11 @@ def save( attrs = frozenset(["items", "type", "label", "doc", "name"]) -class OutputRecordField(RecordField, FieldBase, OutputFormat): +class OutputRecordField(CWLRecordField, FieldBase, OutputFormat): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -3391,7 +5983,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3402,7 +5993,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -3413,7 +6004,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -3426,7 +6017,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -3440,9 +6031,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3451,18 +6043,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3471,7 +6087,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -3481,32 +6097,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3514,15 +6181,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -3532,15 +6223,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -3550,39 +6265,91 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3596,14 +6363,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordField'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -3632,9 +6398,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3671,10 +6437,10 @@ def save( ) -class OutputRecordSchema(RecordSchema, OutputSchema): +class OutputRecordSchema(CWLRecordSchema, OutputSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -3682,7 +6448,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3692,7 +6457,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -3701,7 +6466,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, OutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -3709,7 +6474,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -3717,9 +6482,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3728,18 +6494,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3758,32 +6548,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -3791,15 +6632,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -3809,21 +6674,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -3837,13 +6730,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputRecordSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -3871,9 +6763,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -3899,14 +6791,13 @@ class OutputEnumSchema(EnumSchema, OutputSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -3917,7 +6808,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc @@ -3926,14 +6817,14 @@ def __eq__(self, other: Any) -> bool: return bool( self.name == other.name and self.symbols == other.symbols - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type, self.label, self.doc)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -3941,9 +6832,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -3952,18 +6844,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -3976,35 +6892,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -4012,15 +6982,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -4030,21 +7024,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4058,14 +7080,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputEnumSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, extension_fields=extension_fields, @@ -4091,9 +7112,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -4115,18 +7136,17 @@ def save( attrs = frozenset(["name", "symbols", "type", "label", "doc"]) -class OutputArraySchema(ArraySchema, OutputSchema): +class OutputArraySchema(CWLArraySchema, OutputSchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4136,7 +7156,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -4145,7 +7165,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, OutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -4153,7 +7173,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -4161,9 +7181,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -4172,18 +7193,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -4196,35 +7241,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2, + uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -4232,15 +7331,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -4250,21 +7373,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4278,13 +7429,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'OutputArraySchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -4311,9 +7461,9 @@ def save( if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) r["items"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -4383,7 +7533,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4412,16 +7561,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InlineJavascriptRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InlineJavascriptRequirement": - raise ValidationException("Not a InlineJavascriptRequirement") + raise ValidationException("tried `InlineJavascriptRequirement` but") if "expressionLib" in _doc: try: @@ -4430,21 +7582,49 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("expressionLib") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expressionLib' field is not valid because:", - SourceLine(_doc, "expressionLib", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expressionLib`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expressionLib")))) + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expressionLib` field is not valid because:", + SourceLine(_doc, "expressionLib", str), + [e], + ) + ) else: expressionLib = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4458,12 +7638,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InlineJavascriptRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( expressionLib=expressionLib, extension_fields=extension_fields, @@ -4530,7 +7707,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4556,36 +7732,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SchemaDefRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SchemaDefRequirement": - raise ValidationException("Not a SchemaDefRequirement") + raise ValidationException("tried `SchemaDefRequirement` but") try: + if _doc.get("types") is None: + raise ValidationException("missing required field `types`", None, []) + types = load_field( _doc.get("types"), array_of_union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader, baseuri, loadingOptions, + lc=_doc.get("types") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'types' field is not valid because:", - SourceLine(_doc, "types", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `types`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("types")))) + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `types` field is not valid because:", + SourceLine(_doc, "types", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4599,10 +7809,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SchemaDefRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( types=types, extension_fields=extension_fields, @@ -4664,7 +7873,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4692,28 +7900,56 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SecondaryFileSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("pattern") is None: + raise ValidationException("missing required field `pattern`", None, []) + pattern = load_field( _doc.get("pattern"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("pattern") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'pattern' field is not valid because:", - SourceLine(_doc, "pattern", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `pattern`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("pattern")))) + _errors__.append( + ValidationException( + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `pattern` field is not valid because:", + SourceLine(_doc, "pattern", str), + [e], + ) + ) if "required" in _doc: try: required = load_field( @@ -4721,21 +7957,49 @@ def fromDoc( union_of_None_type_or_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("required") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'required' field is not valid because:", - SourceLine(_doc, "required", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `required`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("required")))) + _errors__.append( + ValidationException( + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `required` field is not valid because:", + SourceLine(_doc, "required", str), + [e], + ) + ) else: required = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4749,10 +8013,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SecondaryFileSchema'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( pattern=pattern, required=required, @@ -4805,7 +8068,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4833,16 +8095,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "LoadListingRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "LoadListingRequirement": - raise ValidationException("Not a LoadListingRequirement") + raise ValidationException("tried `LoadListingRequirement` but") if "loadListing" in _doc: try: @@ -4851,21 +8116,49 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -4879,12 +8172,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'LoadListingRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadListing=loadListing, extension_fields=extension_fields, @@ -4939,7 +8229,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -4967,47 +8256,106 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvironmentDef": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("envName") is None: + raise ValidationException("missing required field `envName`", None, []) + envName = load_field( _doc.get("envName"), strtype, baseuri, loadingOptions, + lc=_doc.get("envName") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envName' field is not valid because:", - SourceLine(_doc, "envName", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envName`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envName")))) + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envName` field is not valid because:", + SourceLine(_doc, "envName", str), + [e], + ) + ) try: + if _doc.get("envValue") is None: + raise ValidationException("missing required field `envValue`", None, []) + envValue = load_field( _doc.get("envValue"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("envValue") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envValue' field is not valid because:", - SourceLine(_doc, "envValue", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envValue`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envValue")))) + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envValue` field is not valid because:", + SourceLine(_doc, "envValue", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5021,10 +8369,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvironmentDef'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envName=envName, envValue=envValue, @@ -5116,7 +8463,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5165,9 +8511,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5179,15 +8526,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "position" in _doc: @@ -5197,15 +8568,39 @@ def fromDoc( union_of_None_type_or_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("position") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'position' field is not valid because:", - SourceLine(_doc, "position", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("position")))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + ) + ) else: position = None if "prefix" in _doc: @@ -5215,15 +8610,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("prefix") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'prefix' field is not valid because:", - SourceLine(_doc, "prefix", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `prefix`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("prefix")))) + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `prefix` field is not valid because:", + SourceLine(_doc, "prefix", str), + [e], + ) + ) else: prefix = None if "separate" in _doc: @@ -5233,15 +8652,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("separate") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'separate' field is not valid because:", - SourceLine(_doc, "separate", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `separate`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("separate")))) + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `separate` field is not valid because:", + SourceLine(_doc, "separate", str), + [e], + ) + ) else: separate = None if "itemSeparator" in _doc: @@ -5251,15 +8694,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("itemSeparator") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'itemSeparator' field is not valid because:", - SourceLine(_doc, "itemSeparator", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `itemSeparator`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("itemSeparator")))) + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `itemSeparator` field is not valid because:", + SourceLine(_doc, "itemSeparator", str), + [e], + ) + ) else: itemSeparator = None if "valueFrom" in _doc: @@ -5269,15 +8736,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None if "shellQuote" in _doc: @@ -5287,21 +8778,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("shellQuote") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'shellQuote' field is not valid because:", - SourceLine(_doc, "shellQuote", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `shellQuote`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("shellQuote")))) + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `shellQuote` field is not valid because:", + SourceLine(_doc, "shellQuote", str), + [e], + ) + ) else: shellQuote = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5315,10 +8834,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, position=position, @@ -5429,7 +8947,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5462,9 +8979,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputBinding": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5476,15 +8994,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -5494,15 +9036,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "glob" in _doc: @@ -5512,15 +9078,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("glob") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'glob' field is not valid because:", - SourceLine(_doc, "glob", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `glob`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("glob")))) + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `glob` field is not valid because:", + SourceLine(_doc, "glob", str), + [e], + ) + ) else: glob = None if "outputEval" in _doc: @@ -5530,21 +9120,49 @@ def fromDoc( union_of_None_type_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outputEval") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputEval' field is not valid because:", - SourceLine(_doc, "outputEval", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputEval`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputEval")))) + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputEval` field is not valid because:", + SourceLine(_doc, "outputEval", str), + [e], + ) + ) else: outputEval = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5558,10 +9176,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandOutputBinding'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( loadContents=loadContents, loadListing=loadListing, @@ -5627,7 +9244,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5652,9 +9268,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineBindable": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5666,21 +9283,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -5694,10 +9339,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineBindable'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( inputBinding=inputBinding, extension_fields=extension_fields, @@ -5739,7 +9383,7 @@ class CommandInputRecordField(InputRecordField, CommandLineBindable): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -5751,7 +9395,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -5762,7 +9405,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -5776,7 +9419,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -5792,7 +9435,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -5809,9 +9452,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -5820,18 +9464,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -5840,7 +9508,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -5850,32 +9518,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -5883,15 +9602,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -5901,15 +9644,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -5919,33 +9686,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -5955,15 +9770,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -5973,15 +9812,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "inputBinding" in _doc: @@ -5991,21 +9854,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6019,16 +9910,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -6060,9 +9948,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6136,7 +10024,7 @@ class CommandInputRecordSchema( ): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -6145,7 +10033,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6155,7 +10042,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -6165,7 +10052,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -6175,7 +10062,14 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( - (self.fields, self.type, self.label, self.doc, self.name, self.inputBinding) + ( + self.fields, + self.type_, + self.label, + self.doc, + self.name, + self.inputBinding, + ) ) @classmethod @@ -6184,9 +10078,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6195,18 +10090,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6225,32 +10144,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandInputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6258,15 +10228,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6276,15 +10270,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6294,21 +10312,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6322,15 +10368,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -6359,9 +10402,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6394,7 +10437,7 @@ class CommandInputEnumSchema(InputEnumSchema, CommandInputSchema, CommandLineBin def __init__( self, symbols: Any, - type: Any, + type_: Any, name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -6402,7 +10445,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6413,7 +10455,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.inputBinding = inputBinding @@ -6423,7 +10465,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.name == other.name and self.symbols == other.symbols - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.inputBinding == other.inputBinding @@ -6435,7 +10477,7 @@ def __hash__(self) -> int: ( self.name, self.symbols, - self.type, + self.type_, self.label, self.doc, self.inputBinding, @@ -6448,9 +10490,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6459,18 +10502,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6483,35 +10550,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6519,15 +10640,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6537,15 +10682,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6555,21 +10724,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6583,16 +10780,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, inputBinding=inputBinding, @@ -6619,9 +10813,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6656,7 +10850,7 @@ class CommandInputArraySchema( def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, @@ -6664,7 +10858,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6674,7 +10867,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -6684,7 +10877,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandInputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -6694,7 +10887,7 @@ def __eq__(self, other: Any) -> bool: def __hash__(self) -> int: return hash( - (self.items, self.type, self.label, self.doc, self.name, self.inputBinding) + (self.items, self.type_, self.label, self.doc, self.name, self.inputBinding) ) @classmethod @@ -6703,9 +10896,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6714,18 +10908,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -6738,35 +10956,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2, + uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -6774,15 +11046,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -6792,15 +11088,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "inputBinding" in _doc: @@ -6810,21 +11130,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -6838,15 +11186,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandInputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -6874,9 +11219,9 @@ def save( if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) r["items"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -6909,7 +11254,7 @@ class CommandOutputRecordField(OutputRecordField): def __init__( self, name: Any, - type: Any, + type_: Any, doc: Optional[Any] = None, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, @@ -6919,7 +11264,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -6930,7 +11274,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.doc = doc self.name = name - self.type = type + self.type_ = type_ self.label = label self.secondaryFiles = secondaryFiles self.streamable = streamable @@ -6942,7 +11286,7 @@ def __eq__(self, other: Any) -> bool: return bool( self.doc == other.doc and self.name == other.name - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.secondaryFiles == other.secondaryFiles and self.streamable == other.streamable @@ -6956,7 +11300,7 @@ def __hash__(self) -> int: ( self.doc, self.name, - self.type, + self.type_, self.label, self.secondaryFiles, self.streamable, @@ -6971,9 +11315,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordField": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -6982,18 +11327,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None, + uri_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7002,7 +11371,7 @@ def fromDoc( if docRoot is not None: name = docRoot else: - raise ValidationException("Missing name") + _errors__.append(ValidationException("missing name")) if not __original_name_is_none: baseuri = name if "doc" in _doc: @@ -7012,32 +11381,83 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7045,15 +11465,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -7063,15 +11507,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -7081,33 +11549,81 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "outputBinding" in _doc: @@ -7117,21 +11633,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7145,16 +11689,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordField'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( doc=doc, name=name, - type=type, + type_=type_, label=label, secondaryFiles=secondaryFiles, streamable=streamable, @@ -7184,9 +11725,9 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7242,7 +11783,7 @@ def save( class CommandOutputRecordSchema(OutputRecordSchema): def __init__( self, - type: Any, + type_: Any, fields: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, @@ -7250,7 +11791,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7260,7 +11800,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.fields = fields - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -7269,7 +11809,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputRecordSchema): return bool( self.fields == other.fields - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -7277,7 +11817,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.fields, self.type, self.label, self.doc, self.name)) + return hash((self.fields, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -7285,9 +11825,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputRecordSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7296,18 +11837,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7326,32 +11891,83 @@ def fromDoc( idmap_fields_union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, baseuri, loadingOptions, + lc=_doc.get("fields") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'fields' field is not valid because:", - SourceLine(_doc, "fields", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `fields`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("fields")))) + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `fields` field is not valid because:", + SourceLine(_doc, "fields", str), + [e], + ) + ) else: fields = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Record_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7359,15 +11975,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7377,21 +12017,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7405,15 +12073,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputRecordSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( fields=fields, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -7441,9 +12106,9 @@ def save( r["fields"] = save( self.fields, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7469,14 +12134,13 @@ class CommandOutputEnumSchema(OutputEnumSchema): def __init__( self, symbols: Any, - type: Any, + type_: Any, name: Optional[Any] = None, label: Optional[Any] = None, doc: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7487,7 +12151,7 @@ def __init__( self.loadingOptions = LoadingOptions() self.name = name self.symbols = symbols - self.type = type + self.type_ = type_ self.label = label self.doc = doc @@ -7496,14 +12160,14 @@ def __eq__(self, other: Any) -> bool: return bool( self.name == other.name and self.symbols == other.symbols - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc ) return False def __hash__(self) -> int: - return hash((self.name, self.symbols, self.type, self.label, self.doc)) + return hash((self.name, self.symbols, self.type_, self.label, self.doc)) @classmethod def fromDoc( @@ -7511,9 +12175,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputEnumSchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7522,18 +12187,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7546,35 +12235,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("symbols") is None: + raise ValidationException("missing required field `symbols`", None, []) + symbols = load_field( _doc.get("symbols"), - uri_array_of_strtype_True_False_None, + uri_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("symbols") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'symbols' field is not valid because:", - SourceLine(_doc, "symbols", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `symbols`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("symbols")))) + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `symbols` field is not valid because:", + SourceLine(_doc, "symbols", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Enum_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7582,15 +12325,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7600,21 +12367,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7628,16 +12423,13 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputEnumSchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( name=name, symbols=symbols, - type=type, + type_=type_, label=label, doc=doc, extension_fields=extension_fields, @@ -7663,9 +12455,9 @@ def save( if self.symbols is not None: u = save_relative_uri(self.symbols, self.name, True, None, relative_uris) r["symbols"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7691,14 +12483,13 @@ class CommandOutputArraySchema(OutputArraySchema): def __init__( self, items: Any, - type: Any, + type_: Any, label: Optional[Any] = None, doc: Optional[Any] = None, name: Optional[Any] = None, extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7708,7 +12499,7 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.items = items - self.type = type + self.type_ = type_ self.label = label self.doc = doc self.name = name @@ -7717,7 +12508,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, CommandOutputArraySchema): return bool( self.items == other.items - and self.type == other.type + and self.type_ == other.type_ and self.label == other.label and self.doc == other.doc and self.name == other.name @@ -7725,7 +12516,7 @@ def __eq__(self, other: Any) -> bool: return False def __hash__(self) -> int: - return hash((self.items, self.type, self.label, self.doc, self.name)) + return hash((self.items, self.type_, self.label, self.doc, self.name)) @classmethod def fromDoc( @@ -7733,9 +12524,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputArraySchema": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -7744,18 +12536,42 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("name") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'name' field is not valid because:", - SourceLine(_doc, "name", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("name")))) + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), + [e], + ) + ) else: name = None @@ -7768,35 +12584,89 @@ def fromDoc( if not __original_name_is_none: baseuri = name try: + if _doc.get("items") is None: + raise ValidationException("missing required field `items`", None, []) + items = load_field( _doc.get("items"), - uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2, + uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None, baseuri, loadingOptions, + lc=_doc.get("items") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'items' field is not valid because:", - SourceLine(_doc, "items", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `items`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("items")))) + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `items` field is not valid because:", + SourceLine(_doc, "items", str), + [e], + ) + ) try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_Array_nameLoader_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "label" in _doc: try: label = load_field( @@ -7804,15 +12674,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -7822,21 +12716,49 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -7850,15 +12772,12 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputArraySchema'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( items=items, - type=type, + type_=type_, label=label, doc=doc, name=name, @@ -7885,9 +12804,9 @@ def save( if self.items is not None: u = save_relative_uri(self.items, self.name, False, 2, relative_uris) r["items"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.name, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) if self.label is not None: r["label"] = save( @@ -7916,7 +12835,7 @@ class CommandInputParameter(InputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -7930,7 +12849,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -7948,7 +12866,7 @@ def __init__( self.loadContents = loadContents self.loadListing = loadListing self.default = default - self.type = type + self.type_ = type_ self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: @@ -7963,7 +12881,7 @@ def __eq__(self, other: Any) -> bool: and self.loadContents == other.loadContents and self.loadListing == other.loadListing and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ and self.inputBinding == other.inputBinding ) return False @@ -7980,7 +12898,7 @@ def __hash__(self) -> int: self.loadContents, self.loadListing, self.default, - self.type, + self.type_, self.inputBinding, ) ) @@ -7991,9 +12909,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -8002,18 +12921,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -8032,15 +12975,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -8050,15 +13017,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -8068,15 +13059,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -8086,33 +13101,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -8122,15 +13185,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -8140,50 +13227,125 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -8191,21 +13353,49 @@ def fromDoc( union_of_None_type_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8219,10 +13409,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandInputParameter'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -8233,7 +13422,7 @@ def fromDoc( loadContents=loadContents, loadListing=loadListing, default=default, - type=type, + type_=type_, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -8298,9 +13487,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -8342,7 +13531,7 @@ class CommandOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -8353,7 +13542,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8368,7 +13556,7 @@ def __init__( self.doc = doc self.id = id self.format = format - self.type = type + self.type_ = type_ self.outputBinding = outputBinding def __eq__(self, other: Any) -> bool: @@ -8380,7 +13568,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ and self.outputBinding == other.outputBinding ) return False @@ -8394,7 +13582,7 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.type, + self.type_, self.outputBinding, ) ) @@ -8405,9 +13593,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -8416,18 +13605,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -8446,15 +13659,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -8464,15 +13701,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -8482,15 +13743,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -8500,50 +13785,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_stdoutLoader_or_stderrLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "outputBinding" in _doc: try: outputBinding = load_field( @@ -8551,21 +13911,49 @@ def fromDoc( union_of_None_type_or_CommandOutputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("outputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputBinding' field is not valid because:", - SourceLine(_doc, "outputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputBinding")))) + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputBinding` field is not valid because:", + SourceLine(_doc, "outputBinding", str), + [e], + ) + ) else: outputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -8579,12 +13967,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'CommandOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -8592,7 +13977,7 @@ def fromDoc( doc=doc, id=id, format=format, - type=type, + type_=type_, outputBinding=outputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -8639,9 +14024,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.outputBinding is not None: r["outputBinding"] = save( @@ -8701,7 +14086,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -8783,33 +14167,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "CommandLineTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "CommandLineTool": - raise ValidationException("Not a CommandLineTool") + raise ValidationException("tried `CommandLineTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -8828,15 +14239,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -8846,47 +14281,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_CommandInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_CommandOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -8894,15 +14407,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -8912,51 +14449,123 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "intent" in _doc: try: intent = load_field( _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None, + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("intent") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'intent' field is not valid because:", - SourceLine(_doc, "intent", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `intent`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("intent")))) + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [e], + ) + ) else: intent = None if "baseCommand" in _doc: @@ -8966,15 +14575,39 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("baseCommand") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'baseCommand' field is not valid because:", - SourceLine(_doc, "baseCommand", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `baseCommand`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("baseCommand")))) + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `baseCommand` field is not valid because:", + SourceLine(_doc, "baseCommand", str), + [e], + ) + ) else: baseCommand = None if "arguments" in _doc: @@ -8984,15 +14617,39 @@ def fromDoc( union_of_None_type_or_array_of_union_of_strtype_or_ExpressionLoader_or_CommandLineBindingLoader, baseuri, loadingOptions, + lc=_doc.get("arguments") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'arguments' field is not valid because:", - SourceLine(_doc, "arguments", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `arguments`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("arguments")))) + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `arguments` field is not valid because:", + SourceLine(_doc, "arguments", str), + [e], + ) + ) else: arguments = None if "stdin" in _doc: @@ -9002,15 +14659,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdin' field is not valid because:", - SourceLine(_doc, "stdin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdin")))) + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdin` field is not valid because:", + SourceLine(_doc, "stdin", str), + [e], + ) + ) else: stdin = None if "stderr" in _doc: @@ -9020,15 +14701,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stderr") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stderr' field is not valid because:", - SourceLine(_doc, "stderr", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stderr`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stderr")))) + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stderr` field is not valid because:", + SourceLine(_doc, "stderr", str), + [e], + ) + ) else: stderr = None if "stdout" in _doc: @@ -9038,15 +14743,39 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("stdout") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'stdout' field is not valid because:", - SourceLine(_doc, "stdout", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `stdout`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("stdout")))) + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `stdout` field is not valid because:", + SourceLine(_doc, "stdout", str), + [e], + ) + ) else: stdout = None if "successCodes" in _doc: @@ -9056,15 +14785,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("successCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'successCodes' field is not valid because:", - SourceLine(_doc, "successCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `successCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("successCodes")))) + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `successCodes` field is not valid because:", + SourceLine(_doc, "successCodes", str), + [e], + ) + ) else: successCodes = None if "temporaryFailCodes" in _doc: @@ -9074,15 +14827,39 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("temporaryFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'temporaryFailCodes' field is not valid because:", - SourceLine(_doc, "temporaryFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `temporaryFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("temporaryFailCodes")))) + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `temporaryFailCodes` field is not valid because:", + SourceLine(_doc, "temporaryFailCodes", str), + [e], + ) + ) else: temporaryFailCodes = None if "permanentFailCodes" in _doc: @@ -9092,21 +14869,49 @@ def fromDoc( union_of_None_type_or_array_of_inttype, baseuri, loadingOptions, + lc=_doc.get("permanentFailCodes") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'permanentFailCodes' field is not valid because:", - SourceLine(_doc, "permanentFailCodes", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `permanentFailCodes`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("permanentFailCodes")))) + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `permanentFailCodes` field is not valid because:", + SourceLine(_doc, "permanentFailCodes", str), + [e], + ) + ) else: permanentFailCodes = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9120,10 +14925,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'CommandLineTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -9341,7 +15145,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9390,16 +15193,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "DockerRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "DockerRequirement": - raise ValidationException("Not a DockerRequirement") + raise ValidationException("tried `DockerRequirement` but") if "dockerPull" in _doc: try: @@ -9408,15 +15214,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerPull") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerPull' field is not valid because:", - SourceLine(_doc, "dockerPull", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerPull`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerPull")))) + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerPull` field is not valid because:", + SourceLine(_doc, "dockerPull", str), + [e], + ) + ) else: dockerPull = None if "dockerLoad" in _doc: @@ -9426,15 +15256,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerLoad") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerLoad' field is not valid because:", - SourceLine(_doc, "dockerLoad", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerLoad`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerLoad")))) + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerLoad` field is not valid because:", + SourceLine(_doc, "dockerLoad", str), + [e], + ) + ) else: dockerLoad = None if "dockerFile" in _doc: @@ -9444,15 +15298,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerFile") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerFile' field is not valid because:", - SourceLine(_doc, "dockerFile", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerFile`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerFile")))) + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerFile` field is not valid because:", + SourceLine(_doc, "dockerFile", str), + [e], + ) + ) else: dockerFile = None if "dockerImport" in _doc: @@ -9462,15 +15340,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImport") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImport' field is not valid because:", - SourceLine(_doc, "dockerImport", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImport`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImport")))) + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImport` field is not valid because:", + SourceLine(_doc, "dockerImport", str), + [e], + ) + ) else: dockerImport = None if "dockerImageId" in _doc: @@ -9480,15 +15382,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerImageId") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerImageId' field is not valid because:", - SourceLine(_doc, "dockerImageId", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerImageId`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerImageId")))) + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerImageId` field is not valid because:", + SourceLine(_doc, "dockerImageId", str), + [e], + ) + ) else: dockerImageId = None if "dockerOutputDirectory" in _doc: @@ -9498,21 +15424,49 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("dockerOutputDirectory") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'dockerOutputDirectory' field is not valid because:", - SourceLine(_doc, "dockerOutputDirectory", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `dockerOutputDirectory`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("dockerOutputDirectory")))) + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `dockerOutputDirectory` field is not valid because:", + SourceLine(_doc, "dockerOutputDirectory", str), + [e], + ) + ) else: dockerOutputDirectory = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9526,10 +15480,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'DockerRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( dockerPull=dockerPull, dockerLoad=dockerLoad, @@ -9632,7 +15585,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9658,36 +15610,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwareRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SoftwareRequirement": - raise ValidationException("Not a SoftwareRequirement") + raise ValidationException("tried `SoftwareRequirement` but") try: + if _doc.get("packages") is None: + raise ValidationException("missing required field `packages`", None, []) + packages = load_field( _doc.get("packages"), idmap_packages_array_of_SoftwarePackageLoader, baseuri, loadingOptions, + lc=_doc.get("packages") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'packages' field is not valid because:", - SourceLine(_doc, "packages", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `packages`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("packages")))) + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `packages` field is not valid because:", + SourceLine(_doc, "packages", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9701,10 +15687,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwareRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( packages=packages, extension_fields=extension_fields, @@ -9750,7 +15735,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9781,28 +15765,56 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SoftwarePackage": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] try: + if _doc.get("package") is None: + raise ValidationException("missing required field `package`", None, []) + package = load_field( _doc.get("package"), strtype, baseuri, loadingOptions, + lc=_doc.get("package") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'package' field is not valid because:", - SourceLine(_doc, "package", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `package`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("package")))) + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `package` field is not valid because:", + SourceLine(_doc, "package", str), + [e], + ) + ) if "version" in _doc: try: version = load_field( @@ -9810,39 +15822,91 @@ def fromDoc( union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("version") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'version' field is not valid because:", - SourceLine(_doc, "version", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `version`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("version")))) + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `version` field is not valid because:", + SourceLine(_doc, "version", str), + [e], + ) + ) else: version = None if "specs" in _doc: try: specs = load_field( _doc.get("specs"), - uri_union_of_None_type_or_array_of_strtype_False_False_None, + uri_union_of_None_type_or_array_of_strtype_False_False_None_True, baseuri, loadingOptions, + lc=_doc.get("specs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'specs' field is not valid because:", - SourceLine(_doc, "specs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `specs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("specs")))) + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `specs` field is not valid because:", + SourceLine(_doc, "specs", str), + [e], + ) + ) else: specs = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -9856,10 +15920,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'SoftwarePackage'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( package=package, version=version, @@ -9924,7 +15987,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -9955,9 +16017,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Dirent": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -9969,32 +16032,83 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entryname") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entryname' field is not valid because:", - SourceLine(_doc, "entryname", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entryname`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entryname")))) + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entryname` field is not valid because:", + SourceLine(_doc, "entryname", str), + [e], + ) + ) else: entryname = None try: + if _doc.get("entry") is None: + raise ValidationException("missing required field `entry`", None, []) + entry = load_field( _doc.get("entry"), union_of_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("entry") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'entry' field is not valid because:", - SourceLine(_doc, "entry", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `entry`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("entry")))) + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `entry` field is not valid because:", + SourceLine(_doc, "entry", str), + [e], + ) + ) if "writable" in _doc: try: writable = load_field( @@ -10002,21 +16116,49 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("writable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'writable' field is not valid because:", - SourceLine(_doc, "writable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `writable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("writable")))) + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `writable` field is not valid because:", + SourceLine(_doc, "writable", str), + [e], + ) + ) else: writable = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10030,10 +16172,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Dirent'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( entryname=entryname, entry=entry, @@ -10093,7 +16234,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10119,36 +16259,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InitialWorkDirRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InitialWorkDirRequirement": - raise ValidationException("Not a InitialWorkDirRequirement") + raise ValidationException("tried `InitialWorkDirRequirement` but") try: + if _doc.get("listing") is None: + raise ValidationException("missing required field `listing`", None, []) + listing = load_field( _doc.get("listing"), union_of_ExpressionLoader_or_array_of_union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader, baseuri, loadingOptions, + lc=_doc.get("listing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'listing' field is not valid because:", - SourceLine(_doc, "listing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `listing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("listing")))) + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `listing` field is not valid because:", + SourceLine(_doc, "listing", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10162,12 +16336,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InitialWorkDirRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( listing=listing, extension_fields=extension_fields, @@ -10217,7 +16388,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10243,36 +16413,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "EnvVarRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "EnvVarRequirement": - raise ValidationException("Not a EnvVarRequirement") + raise ValidationException("tried `EnvVarRequirement` but") try: + if _doc.get("envDef") is None: + raise ValidationException("missing required field `envDef`", None, []) + envDef = load_field( _doc.get("envDef"), idmap_envDef_array_of_EnvironmentDefLoader, baseuri, loadingOptions, + lc=_doc.get("envDef") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'envDef' field is not valid because:", - SourceLine(_doc, "envDef", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `envDef`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("envDef")))) + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `envDef` field is not valid because:", + SourceLine(_doc, "envDef", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10286,10 +16490,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'EnvVarRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( envDef=envDef, extension_fields=extension_fields, @@ -10343,7 +16546,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10368,21 +16570,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ShellCommandRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ShellCommandRequirement": - raise ValidationException("Not a ShellCommandRequirement") + raise ValidationException("tried `ShellCommandRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10394,12 +16603,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ShellCommandRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -10474,7 +16680,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10529,16 +16734,19 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ResourceRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ResourceRequirement": - raise ValidationException("Not a ResourceRequirement") + raise ValidationException("tried `ResourceRequirement` but") if "coresMin" in _doc: try: @@ -10547,15 +16755,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMin' field is not valid because:", - SourceLine(_doc, "coresMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMin")))) + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMin` field is not valid because:", + SourceLine(_doc, "coresMin", str), + [e], + ) + ) else: coresMin = None if "coresMax" in _doc: @@ -10565,15 +16797,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("coresMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'coresMax' field is not valid because:", - SourceLine(_doc, "coresMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `coresMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("coresMax")))) + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `coresMax` field is not valid because:", + SourceLine(_doc, "coresMax", str), + [e], + ) + ) else: coresMax = None if "ramMin" in _doc: @@ -10583,15 +16839,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMin' field is not valid because:", - SourceLine(_doc, "ramMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMin")))) + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMin` field is not valid because:", + SourceLine(_doc, "ramMin", str), + [e], + ) + ) else: ramMin = None if "ramMax" in _doc: @@ -10601,15 +16881,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("ramMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'ramMax' field is not valid because:", - SourceLine(_doc, "ramMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `ramMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("ramMax")))) + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `ramMax` field is not valid because:", + SourceLine(_doc, "ramMax", str), + [e], + ) + ) else: ramMax = None if "tmpdirMin" in _doc: @@ -10619,15 +16923,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMin' field is not valid because:", - SourceLine(_doc, "tmpdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMin")))) + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMin` field is not valid because:", + SourceLine(_doc, "tmpdirMin", str), + [e], + ) + ) else: tmpdirMin = None if "tmpdirMax" in _doc: @@ -10637,15 +16965,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("tmpdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'tmpdirMax' field is not valid because:", - SourceLine(_doc, "tmpdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tmpdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("tmpdirMax")))) + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tmpdirMax` field is not valid because:", + SourceLine(_doc, "tmpdirMax", str), + [e], + ) + ) else: tmpdirMax = None if "outdirMin" in _doc: @@ -10655,15 +17007,39 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMin") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMin' field is not valid because:", - SourceLine(_doc, "outdirMin", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMin`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMin")))) + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMin` field is not valid because:", + SourceLine(_doc, "outdirMin", str), + [e], + ) + ) else: outdirMin = None if "outdirMax" in _doc: @@ -10673,21 +17049,49 @@ def fromDoc( union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("outdirMax") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outdirMax' field is not valid because:", - SourceLine(_doc, "outdirMax", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outdirMax`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outdirMax")))) + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outdirMax` field is not valid because:", + SourceLine(_doc, "outdirMax", str), + [e], + ) + ) else: outdirMax = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10701,10 +17105,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ResourceRequirement'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( coresMin=coresMin, coresMax=coresMax, @@ -10820,7 +17223,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10848,36 +17250,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkReuse": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "WorkReuse": - raise ValidationException("Not a WorkReuse") + raise ValidationException("tried `WorkReuse` but") try: + if _doc.get("enableReuse") is None: + raise ValidationException("missing required field `enableReuse`", None, []) + enableReuse = load_field( _doc.get("enableReuse"), union_of_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("enableReuse") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'enableReuse' field is not valid because:", - SourceLine(_doc, "enableReuse", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `enableReuse`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("enableReuse")))) + _errors__.append( + ValidationException( + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `enableReuse` field is not valid because:", + SourceLine(_doc, "enableReuse", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -10891,10 +17327,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkReuse'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( enableReuse=enableReuse, extension_fields=extension_fields, @@ -10960,7 +17395,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -10989,36 +17423,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "NetworkAccess": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "NetworkAccess": - raise ValidationException("Not a NetworkAccess") + raise ValidationException("tried `NetworkAccess` but") try: + if _doc.get("networkAccess") is None: + raise ValidationException("missing required field `networkAccess`", None, []) + networkAccess = load_field( _doc.get("networkAccess"), union_of_booltype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("networkAccess") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'networkAccess' field is not valid because:", - SourceLine(_doc, "networkAccess", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `networkAccess`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("networkAccess")))) + _errors__.append( + ValidationException( + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `networkAccess` field is not valid because:", + SourceLine(_doc, "networkAccess", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11032,10 +17500,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'NetworkAccess'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( networkAccess=networkAccess, extension_fields=extension_fields, @@ -11116,7 +17583,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11145,36 +17611,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "InplaceUpdateRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "InplaceUpdateRequirement": - raise ValidationException("Not a InplaceUpdateRequirement") + raise ValidationException("tried `InplaceUpdateRequirement` but") try: + if _doc.get("inplaceUpdate") is None: + raise ValidationException("missing required field `inplaceUpdate`", None, []) + inplaceUpdate = load_field( _doc.get("inplaceUpdate"), booltype, baseuri, loadingOptions, + lc=_doc.get("inplaceUpdate") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inplaceUpdate' field is not valid because:", - SourceLine(_doc, "inplaceUpdate", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inplaceUpdate`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inplaceUpdate")))) + _errors__.append( + ValidationException( + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inplaceUpdate` field is not valid because:", + SourceLine(_doc, "inplaceUpdate", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11188,12 +17688,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'InplaceUpdateRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( inplaceUpdate=inplaceUpdate, extension_fields=extension_fields, @@ -11251,7 +17748,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11279,36 +17775,70 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ToolTimeLimit": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ToolTimeLimit": - raise ValidationException("Not a ToolTimeLimit") + raise ValidationException("tried `ToolTimeLimit` but") try: + if _doc.get("timelimit") is None: + raise ValidationException("missing required field `timelimit`", None, []) + timelimit = load_field( _doc.get("timelimit"), union_of_inttype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("timelimit") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'timelimit' field is not valid because:", - SourceLine(_doc, "timelimit", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `timelimit`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("timelimit")))) + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `timelimit` field is not valid because:", + SourceLine(_doc, "timelimit", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11322,10 +17852,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ToolTimeLimit'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( timelimit=timelimit, extension_fields=extension_fields, @@ -11368,7 +17897,7 @@ def save( class ExpressionToolOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -11378,7 +17907,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11393,7 +17921,7 @@ def __init__( self.doc = doc self.id = id self.format = format - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, ExpressionToolOutputParameter): @@ -11404,7 +17932,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -11417,7 +17945,7 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.type, + self.type_, ) ) @@ -11427,9 +17955,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionToolOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11438,18 +17967,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11468,15 +18021,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -11486,15 +18063,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -11504,15 +18105,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -11522,54 +18147,133 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11583,12 +18287,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ExpressionToolOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -11596,7 +18297,7 @@ def fromDoc( doc=doc, id=id, format=format, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -11642,9 +18343,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -11663,7 +18364,7 @@ def save( class WorkflowInputParameter(InputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -11677,7 +18378,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -11695,7 +18395,7 @@ def __init__( self.loadContents = loadContents self.loadListing = loadListing self.default = default - self.type = type + self.type_ = type_ self.inputBinding = inputBinding def __eq__(self, other: Any) -> bool: @@ -11710,7 +18410,7 @@ def __eq__(self, other: Any) -> bool: and self.loadContents == other.loadContents and self.loadListing == other.loadListing and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ and self.inputBinding == other.inputBinding ) return False @@ -11727,7 +18427,7 @@ def __hash__(self) -> int: self.loadContents, self.loadListing, self.default, - self.type, + self.type_, self.inputBinding, ) ) @@ -11738,9 +18438,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -11749,18 +18450,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -11779,15 +18504,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -11797,15 +18546,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -11815,15 +18588,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -11833,33 +18630,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -11869,15 +18714,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -11887,50 +18756,125 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) if "inputBinding" in _doc: try: inputBinding = load_field( @@ -11938,21 +18882,49 @@ def fromDoc( union_of_None_type_or_InputBindingLoader, baseuri, loadingOptions, + lc=_doc.get("inputBinding") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputBinding' field is not valid because:", - SourceLine(_doc, "inputBinding", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputBinding`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputBinding")))) + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputBinding` field is not valid because:", + SourceLine(_doc, "inputBinding", str), + [e], + ) + ) else: inputBinding = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -11966,12 +18938,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'WorkflowInputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -11982,7 +18951,7 @@ def fromDoc( loadContents=loadContents, loadListing=loadListing, default=default, - type=type, + type_=type_, inputBinding=inputBinding, extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -12047,9 +19016,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) if self.inputBinding is not None: r["inputBinding"] = save( @@ -12111,7 +19080,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12172,33 +19140,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ExpressionTool": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ExpressionTool": - raise ValidationException("Not a ExpressionTool") + raise ValidationException("tried `ExpressionTool` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -12217,15 +19212,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -12235,47 +19254,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_ExpressionToolOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -12283,15 +19380,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -12301,72 +19422,175 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "intent" in _doc: try: intent = load_field( _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None, + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("intent") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'intent' field is not valid because:", - SourceLine(_doc, "intent", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `intent`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("intent")))) + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [e], + ) + ) else: intent = None try: + if _doc.get("expression") is None: + raise ValidationException("missing required field `expression`", None, []) + expression = load_field( _doc.get("expression"), ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("expression") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'expression' field is not valid because:", - SourceLine(_doc, "expression", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `expression`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("expression")))) + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `expression` field is not valid because:", + SourceLine(_doc, "expression", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12380,10 +19604,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'ExpressionTool'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -12497,7 +19720,7 @@ class WorkflowOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -12510,7 +19733,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -12528,7 +19750,7 @@ def __init__( self.outputSource = outputSource self.linkMerge = linkMerge self.pickValue = pickValue - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, WorkflowOutputParameter): @@ -12542,7 +19764,7 @@ def __eq__(self, other: Any) -> bool: and self.outputSource == other.outputSource and self.linkMerge == other.linkMerge and self.pickValue == other.pickValue - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -12558,7 +19780,7 @@ def __hash__(self) -> int: self.outputSource, self.linkMerge, self.pickValue, - self.type, + self.type_, ) ) @@ -12568,9 +19790,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -12579,18 +19802,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -12609,15 +19856,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -12627,15 +19898,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -12645,15 +19940,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -12663,51 +19982,123 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "outputSource" in _doc: try: outputSource = load_field( _doc.get("outputSource"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None, baseuri, loadingOptions, + lc=_doc.get("outputSource") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputSource' field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputSource`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputSource")))) + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), + [e], + ) + ) else: outputSource = None if "linkMerge" in _doc: @@ -12717,15 +20108,39 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None if "pickValue" in _doc: @@ -12735,36 +20150,91 @@ def fromDoc( union_of_None_type_or_PickValueMethodLoader, baseuri, loadingOptions, + lc=_doc.get("pickValue") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'pickValue' field is not valid because:", - SourceLine(_doc, "pickValue", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `pickValue`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("pickValue")))) + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [e], + ) + ) else: pickValue = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -12778,12 +20248,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'WorkflowOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -12794,7 +20261,7 @@ def fromDoc( outputSource=outputSource, linkMerge=linkMerge, pickValue=pickValue, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -12851,9 +20318,9 @@ def save( r["pickValue"] = save( self.pickValue, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -13011,7 +20478,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13066,9 +20532,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepInput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -13077,18 +20544,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13104,18 +20595,42 @@ def fromDoc( try: source = load_field( _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, baseuri, loadingOptions, + lc=_doc.get("source") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'source' field is not valid because:", - SourceLine(_doc, "source", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `source`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("source")))) + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), + [e], + ) + ) else: source = None if "linkMerge" in _doc: @@ -13125,15 +20640,39 @@ def fromDoc( union_of_None_type_or_LinkMergeMethodLoader, baseuri, loadingOptions, + lc=_doc.get("linkMerge") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'linkMerge' field is not valid because:", - SourceLine(_doc, "linkMerge", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `linkMerge`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("linkMerge")))) + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `linkMerge` field is not valid because:", + SourceLine(_doc, "linkMerge", str), + [e], + ) + ) else: linkMerge = None if "pickValue" in _doc: @@ -13143,15 +20682,39 @@ def fromDoc( union_of_None_type_or_PickValueMethodLoader, baseuri, loadingOptions, + lc=_doc.get("pickValue") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'pickValue' field is not valid because:", - SourceLine(_doc, "pickValue", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `pickValue`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("pickValue")))) + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `pickValue` field is not valid because:", + SourceLine(_doc, "pickValue", str), + [e], + ) + ) else: pickValue = None if "loadContents" in _doc: @@ -13161,15 +20724,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -13179,15 +20766,39 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "label" in _doc: @@ -13197,33 +20808,81 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None if "valueFrom" in _doc: @@ -13233,21 +20892,49 @@ def fromDoc( union_of_None_type_or_strtype_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("valueFrom") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'valueFrom' field is not valid because:", - SourceLine(_doc, "valueFrom", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `valueFrom`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("valueFrom")))) + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `valueFrom` field is not valid because:", + SourceLine(_doc, "valueFrom", str), + [e], + ) + ) else: valueFrom = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13261,10 +20948,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepInput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, source=source, @@ -13375,7 +21061,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13400,9 +21085,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStepOutput": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -13411,18 +21097,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13437,7 +21147,11 @@ def fromDoc( extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13449,10 +21163,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStepOutput'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, extension_fields=extension_fields, @@ -13587,7 +21300,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -13648,9 +21360,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "WorkflowStep": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -13659,18 +21372,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -13689,15 +21426,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -13707,47 +21468,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("in") is None: + raise ValidationException("missing required field `in`", None, []) + in_ = load_field( _doc.get("in"), idmap_in__array_of_WorkflowStepInputLoader, baseuri, loadingOptions, + lc=_doc.get("in") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'in' field is not valid because:", - SourceLine(_doc, "in", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("in")))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + ) + ) try: + if _doc.get("out") is None: + raise ValidationException("missing required field `out`", None, []) + out = load_field( _doc.get("out"), - uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None, + uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("out") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'out' field is not valid because:", - SourceLine(_doc, "out", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `out`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("out")))) + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -13755,15 +21594,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -13773,34 +21636,85 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) try: + if _doc.get("run") is None: + raise ValidationException("missing required field `run`", None, []) + run = load_field( _doc.get("run"), - uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None, + uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None_None, subscope_baseuri, loadingOptions, + lc=_doc.get("run") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'run' field is not valid because:", - SourceLine(_doc, "run", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `run`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("run")))) + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), + [e], + ) + ) if "when" in _doc: try: when = load_field( @@ -13808,57 +21722,133 @@ def fromDoc( union_of_None_type_or_ExpressionLoader, baseuri, loadingOptions, + lc=_doc.get("when") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'when' field is not valid because:", - SourceLine(_doc, "when", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `when`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("when")))) + _errors__.append( + ValidationException( + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), + [e], + ) + ) else: when = None if "scatter" in _doc: try: scatter = load_field( _doc.get("scatter"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0, + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None, baseuri, loadingOptions, + lc=_doc.get("scatter") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatter' field is not valid because:", - SourceLine(_doc, "scatter", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatter`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatter")))) + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatter` field is not valid because:", + SourceLine(_doc, "scatter", str), + [e], + ) + ) else: scatter = None if "scatterMethod" in _doc: try: scatterMethod = load_field( _doc.get("scatterMethod"), - uri_union_of_None_type_or_ScatterMethodLoader_False_True_None, + uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("scatterMethod") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'scatterMethod' field is not valid because:", - SourceLine(_doc, "scatterMethod", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `scatterMethod`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("scatterMethod")))) + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `scatterMethod` field is not valid because:", + SourceLine(_doc, "scatterMethod", str), + [e], + ) + ) else: scatterMethod = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -13872,10 +21862,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'WorkflowStep'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -14046,7 +22035,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14107,33 +22095,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Workflow": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Workflow": - raise ValidationException("Not a Workflow") + raise ValidationException("tried `Workflow` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -14152,15 +22167,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -14170,47 +22209,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_WorkflowInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_WorkflowOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -14218,15 +22335,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -14236,72 +22377,175 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "intent" in _doc: try: intent = load_field( _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None, + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("intent") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'intent' field is not valid because:", - SourceLine(_doc, "intent", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `intent`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("intent")))) + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [e], + ) + ) else: intent = None try: + if _doc.get("steps") is None: + raise ValidationException("missing required field `steps`", None, []) + steps = load_field( _doc.get("steps"), idmap_steps_union_of_array_of_WorkflowStepLoader, baseuri, loadingOptions, + lc=_doc.get("steps") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'steps' field is not valid because:", - SourceLine(_doc, "steps", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `steps`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("steps")))) + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `steps` field is not valid because:", + SourceLine(_doc, "steps", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14315,10 +22559,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Workflow'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -14427,7 +22670,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14452,21 +22694,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "SubworkflowFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "SubworkflowFeatureRequirement": - raise ValidationException("Not a SubworkflowFeatureRequirement") + raise ValidationException("tried `SubworkflowFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14478,12 +22727,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'SubworkflowFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14527,7 +22773,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14552,21 +22797,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "ScatterFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "ScatterFeatureRequirement": - raise ValidationException("Not a ScatterFeatureRequirement") + raise ValidationException("tried `ScatterFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14578,12 +22830,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'ScatterFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14627,7 +22876,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14652,21 +22900,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "MultipleInputFeatureRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "MultipleInputFeatureRequirement": - raise ValidationException("Not a MultipleInputFeatureRequirement") + raise ValidationException("tried `MultipleInputFeatureRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14678,12 +22933,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'MultipleInputFeatureRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14727,7 +22979,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14752,21 +23003,28 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "StepInputExpressionRequirement": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "StepInputExpressionRequirement": - raise ValidationException("Not a StepInputExpressionRequirement") + raise ValidationException("tried `StepInputExpressionRequirement` but") extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -14778,12 +23036,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'StepInputExpressionRequirement'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( extension_fields=extension_fields, loadingOptions=loadingOptions, @@ -14823,7 +23078,7 @@ class OperationInputParameter(InputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -14836,7 +23091,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -14854,7 +23108,7 @@ def __init__( self.loadContents = loadContents self.loadListing = loadListing self.default = default - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, OperationInputParameter): @@ -14868,7 +23122,7 @@ def __eq__(self, other: Any) -> bool: and self.loadContents == other.loadContents and self.loadListing == other.loadListing and self.default == other.default - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -14884,7 +23138,7 @@ def __hash__(self) -> int: self.loadContents, self.loadListing, self.default, - self.type, + self.type_, ) ) @@ -14894,9 +23148,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OperationInputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -14905,18 +23160,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -14935,15 +23214,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -14953,15 +23256,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -14971,15 +23298,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -14989,33 +23340,81 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None if "loadContents" in _doc: @@ -15025,15 +23424,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("loadContents") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadContents' field is not valid because:", - SourceLine(_doc, "loadContents", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadContents`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadContents")))) + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadContents` field is not valid because:", + SourceLine(_doc, "loadContents", str), + [e], + ) + ) else: loadContents = None if "loadListing" in _doc: @@ -15043,54 +23466,133 @@ def fromDoc( union_of_None_type_or_LoadListingEnumLoader, baseuri, loadingOptions, + lc=_doc.get("loadListing") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'loadListing' field is not valid because:", - SourceLine(_doc, "loadListing", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `loadListing`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("loadListing")))) + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `loadListing` field is not valid because:", + SourceLine(_doc, "loadListing", str), + [e], + ) + ) else: loadListing = None if "default" in _doc: try: default = load_field( _doc.get("default"), - union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type, + union_of_None_type_or_CWLObjectTypeLoader, baseuri, loadingOptions, + lc=_doc.get("default") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'default' field is not valid because:", - SourceLine(_doc, "default", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `default`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("default")))) + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), + [e], + ) + ) else: default = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -15104,12 +23606,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'OperationInputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -15120,7 +23619,7 @@ def fromDoc( loadContents=loadContents, loadListing=loadListing, default=default, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -15184,9 +23683,9 @@ def save( r["default"] = save( self.default, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -15221,7 +23720,7 @@ class OperationOutputParameter(OutputParameter): def __init__( self, - type: Any, + type_: Any, label: Optional[Any] = None, secondaryFiles: Optional[Any] = None, streamable: Optional[Any] = None, @@ -15231,7 +23730,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -15246,7 +23744,7 @@ def __init__( self.doc = doc self.id = id self.format = format - self.type = type + self.type_ = type_ def __eq__(self, other: Any) -> bool: if isinstance(other, OperationOutputParameter): @@ -15257,7 +23755,7 @@ def __eq__(self, other: Any) -> bool: and self.doc == other.doc and self.id == other.id and self.format == other.format - and self.type == other.type + and self.type_ == other.type_ ) return False @@ -15270,7 +23768,7 @@ def __hash__(self) -> int: self.doc, self.id, self.format, - self.type, + self.type_, ) ) @@ -15280,9 +23778,10 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "OperationOutputParameter": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename @@ -15291,18 +23790,42 @@ def fromDoc( try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -15321,15 +23844,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "secondaryFiles" in _doc: @@ -15339,15 +23886,39 @@ def fromDoc( secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, baseuri, loadingOptions, + lc=_doc.get("secondaryFiles") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'secondaryFiles' field is not valid because:", - SourceLine(_doc, "secondaryFiles", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `secondaryFiles`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("secondaryFiles")))) + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `secondaryFiles` field is not valid because:", + SourceLine(_doc, "secondaryFiles", str), + [e], + ) + ) else: secondaryFiles = None if "streamable" in _doc: @@ -15357,15 +23928,39 @@ def fromDoc( union_of_None_type_or_booltype, baseuri, loadingOptions, + lc=_doc.get("streamable") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'streamable' field is not valid because:", - SourceLine(_doc, "streamable", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `streamable`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("streamable")))) + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `streamable` field is not valid because:", + SourceLine(_doc, "streamable", str), + [e], + ) + ) else: streamable = None if "doc" in _doc: @@ -15375,54 +23970,133 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None if "format" in _doc: try: format = load_field( _doc.get("format"), - uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None, + uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True, baseuri, loadingOptions, + lc=_doc.get("format") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'format' field is not valid because:", - SourceLine(_doc, "format", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `format`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("format")))) + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), + [e], + ) + ) else: format = None try: - type = load_field( + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( _doc.get("type"), typedsl_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_2, baseuri, loadingOptions, + lc=_doc.get("type") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'type' field is not valid because:", - SourceLine(_doc, "type", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("type")))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + ) + ) extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -15436,12 +24110,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException( - "Trying 'OperationOutputParameter'", None, _errors__ - ) + raise ValidationException("", None, _errors__, "*") _constructed = cls( label=label, secondaryFiles=secondaryFiles, @@ -15449,7 +24120,7 @@ def fromDoc( doc=doc, id=id, format=format, - type=type, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -15495,9 +24166,9 @@ def save( if self.format is not None: u = save_relative_uri(self.format, self.id, True, None, relative_uris) r["format"] = u - if self.type is not None: + if self.type_ is not None: r["type"] = save( - self.type, top=False, base_url=self.id, relative_uris=relative_uris + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -15539,7 +24210,6 @@ def __init__( extension_fields: Optional[Dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: - if extension_fields: self.extension_fields = extension_fields else: @@ -15597,33 +24267,60 @@ def fromDoc( doc: Any, baseuri: str, loadingOptions: LoadingOptions, - docRoot: Optional[str] = None, + docRoot: Optional[str] = None ) -> "Operation": _doc = copy.copy(doc) + if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] + if "class" not in _doc: + raise ValidationException("Missing 'class' field") if _doc.get("class") != "Operation": - raise ValidationException("Not a Operation") + raise ValidationException("tried `Operation` but") if "id" in _doc: try: id = load_field( _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("id") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'id' field is not valid because:", - SourceLine(_doc, "id", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("id")))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + ) + ) else: id = None @@ -15642,15 +24339,39 @@ def fromDoc( union_of_None_type_or_strtype, baseuri, loadingOptions, + lc=_doc.get("label") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'label' field is not valid because:", - SourceLine(_doc, "label", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("label")))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + ) + ) else: label = None if "doc" in _doc: @@ -15660,47 +24381,125 @@ def fromDoc( union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, + lc=_doc.get("doc") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'doc' field is not valid because:", - SourceLine(_doc, "doc", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("doc")))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + ) + ) else: doc = None try: + if _doc.get("inputs") is None: + raise ValidationException("missing required field `inputs`", None, []) + inputs = load_field( _doc.get("inputs"), idmap_inputs_array_of_OperationInputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("inputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'inputs' field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("inputs")))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + ) + ) try: + if _doc.get("outputs") is None: + raise ValidationException("missing required field `outputs`", None, []) + outputs = load_field( _doc.get("outputs"), idmap_outputs_array_of_OperationOutputParameterLoader, baseuri, loadingOptions, + lc=_doc.get("outputs") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'outputs' field is not valid because:", - SourceLine(_doc, "outputs", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("outputs")))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + ) + ) if "requirements" in _doc: try: requirements = load_field( @@ -15708,15 +24507,39 @@ def fromDoc( idmap_requirements_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, baseuri, loadingOptions, + lc=_doc.get("requirements") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'requirements' field is not valid because:", - SourceLine(_doc, "requirements", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `requirements`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("requirements")))) + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `requirements` field is not valid because:", + SourceLine(_doc, "requirements", str), + [e], + ) + ) else: requirements = None if "hints" in _doc: @@ -15726,57 +24549,133 @@ def fromDoc( idmap_hints_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_Any_type, baseuri, loadingOptions, + lc=_doc.get("hints") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'hints' field is not valid because:", - SourceLine(_doc, "hints", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `hints`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("hints")))) + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `hints` field is not valid because:", + SourceLine(_doc, "hints", str), + [e], + ) + ) else: hints = None if "cwlVersion" in _doc: try: cwlVersion = load_field( _doc.get("cwlVersion"), - uri_union_of_None_type_or_CWLVersionLoader_False_True_None, + uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None, baseuri, loadingOptions, + lc=_doc.get("cwlVersion") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'cwlVersion' field is not valid because:", - SourceLine(_doc, "cwlVersion", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `cwlVersion`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("cwlVersion")))) + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `cwlVersion` field is not valid because:", + SourceLine(_doc, "cwlVersion", str), + [e], + ) + ) else: cwlVersion = None if "intent" in _doc: try: intent = load_field( _doc.get("intent"), - uri_union_of_None_type_or_array_of_strtype_True_False_None, + uri_union_of_None_type_or_array_of_strtype_True_False_None_None, baseuri, loadingOptions, + lc=_doc.get("intent") ) + except ValidationException as e: - _errors__.append( - ValidationException( - "the 'intent' field is not valid because:", - SourceLine(_doc, "intent", str), - [e], + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `intent`": + _errors__.append( + ValidationException( + str(e), + None + ) ) - ) + else: + if error_message != str(e): + val_type = convert_typing(extract_type(type(_doc.get("intent")))) + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `intent` field is not valid because:", + SourceLine(_doc, "intent", str), + [e], + ) + ) else: intent = None extension_fields: Dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: - if ":" in k: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: ex = expand_url( k, "", loadingOptions, scoped_id=False, vocab_term=False ) @@ -15790,10 +24689,9 @@ def fromDoc( SourceLine(_doc, k, str), ) ) - break if _errors__: - raise ValidationException("Trying 'Operation'", None, _errors__) + raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, label=label, @@ -15887,6 +24785,11 @@ def save( _vocab = { "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", + "CWLArraySchema": "https://w3id.org/cwl/cwl#CWLArraySchema", + "CWLInputFile": "https://w3id.org/cwl/cwl#CWLInputFile", + "CWLObjectType": "https://w3id.org/cwl/cwl#CWLObjectType", + "CWLRecordField": "https://w3id.org/cwl/cwl#CWLRecordField", + "CWLRecordSchema": "https://w3id.org/cwl/cwl#CWLRecordSchema", "CWLType": "https://w3id.org/cwl/cwl#CWLType", "CWLVersion": "https://w3id.org/cwl/cwl#CWLVersion", "CommandInputArraySchema": "https://w3id.org/cwl/cwl#CommandInputArraySchema", @@ -15935,6 +24838,7 @@ def save( "LoadContents": "https://w3id.org/cwl/cwl#LoadContents", "LoadListingEnum": "https://w3id.org/cwl/cwl#LoadListingEnum", "LoadListingRequirement": "https://w3id.org/cwl/cwl#LoadListingRequirement", + "MapSchema": "https://w3id.org/cwl/salad#MapSchema", "MultipleInputFeatureRequirement": "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement", "NetworkAccess": "https://w3id.org/cwl/cwl#NetworkAccess", "Operation": "https://w3id.org/cwl/cwl#Operation", @@ -15966,6 +24870,7 @@ def save( "StepInputExpressionRequirement": "https://w3id.org/cwl/cwl#StepInputExpressionRequirement", "SubworkflowFeatureRequirement": "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement", "ToolTimeLimit": "https://w3id.org/cwl/cwl#ToolTimeLimit", + "UnionSchema": "https://w3id.org/cwl/salad#UnionSchema", "WorkReuse": "https://w3id.org/cwl/cwl#WorkReuse", "Workflow": "https://w3id.org/cwl/cwl#Workflow", "WorkflowInputParameter": "https://w3id.org/cwl/cwl#WorkflowInputParameter", @@ -15995,6 +24900,7 @@ def save( "float": "http://www.w3.org/2001/XMLSchema#float", "int": "http://www.w3.org/2001/XMLSchema#int", "long": "http://www.w3.org/2001/XMLSchema#long", + "map": "https://w3id.org/cwl/salad#map", "merge_flattened": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened", "merge_nested": "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested", "nested_crossproduct": "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct", @@ -16007,6 +24913,7 @@ def save( "stdout": "https://w3id.org/cwl/cwl#stdout", "string": "http://www.w3.org/2001/XMLSchema#string", "the_only_non_null": "https://w3id.org/cwl/cwl#PickValueMethod/the_only_non_null", + "union": "https://w3id.org/cwl/salad#union", "v1.0": "https://w3id.org/cwl/cwl#v1.0", "v1.0.dev4": "https://w3id.org/cwl/cwl#v1.0.dev4", "v1.1": "https://w3id.org/cwl/cwl#v1.1", @@ -16021,6 +24928,11 @@ def save( _rvocab = { "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", + "https://w3id.org/cwl/cwl#CWLArraySchema": "CWLArraySchema", + "https://w3id.org/cwl/cwl#CWLInputFile": "CWLInputFile", + "https://w3id.org/cwl/cwl#CWLObjectType": "CWLObjectType", + "https://w3id.org/cwl/cwl#CWLRecordField": "CWLRecordField", + "https://w3id.org/cwl/cwl#CWLRecordSchema": "CWLRecordSchema", "https://w3id.org/cwl/cwl#CWLType": "CWLType", "https://w3id.org/cwl/cwl#CWLVersion": "CWLVersion", "https://w3id.org/cwl/cwl#CommandInputArraySchema": "CommandInputArraySchema", @@ -16069,6 +24981,7 @@ def save( "https://w3id.org/cwl/cwl#LoadContents": "LoadContents", "https://w3id.org/cwl/cwl#LoadListingEnum": "LoadListingEnum", "https://w3id.org/cwl/cwl#LoadListingRequirement": "LoadListingRequirement", + "https://w3id.org/cwl/salad#MapSchema": "MapSchema", "https://w3id.org/cwl/cwl#MultipleInputFeatureRequirement": "MultipleInputFeatureRequirement", "https://w3id.org/cwl/cwl#NetworkAccess": "NetworkAccess", "https://w3id.org/cwl/cwl#Operation": "Operation", @@ -16100,6 +25013,7 @@ def save( "https://w3id.org/cwl/cwl#StepInputExpressionRequirement": "StepInputExpressionRequirement", "https://w3id.org/cwl/cwl#SubworkflowFeatureRequirement": "SubworkflowFeatureRequirement", "https://w3id.org/cwl/cwl#ToolTimeLimit": "ToolTimeLimit", + "https://w3id.org/cwl/salad#UnionSchema": "UnionSchema", "https://w3id.org/cwl/cwl#WorkReuse": "WorkReuse", "https://w3id.org/cwl/cwl#Workflow": "Workflow", "https://w3id.org/cwl/cwl#WorkflowInputParameter": "WorkflowInputParameter", @@ -16129,6 +25043,7 @@ def save( "http://www.w3.org/2001/XMLSchema#float": "float", "http://www.w3.org/2001/XMLSchema#int": "int", "http://www.w3.org/2001/XMLSchema#long": "long", + "https://w3id.org/cwl/salad#map": "map", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_flattened": "merge_flattened", "https://w3id.org/cwl/cwl#LinkMergeMethod/merge_nested": "merge_nested", "https://w3id.org/cwl/cwl#ScatterMethod/nested_crossproduct": "nested_crossproduct", @@ -16141,6 +25056,7 @@ def save( "https://w3id.org/cwl/cwl#stdout": "stdout", "http://www.w3.org/2001/XMLSchema#string": "string", "https://w3id.org/cwl/cwl#PickValueMethod/the_only_non_null": "the_only_non_null", + "https://w3id.org/cwl/salad#union": "union", "https://w3id.org/cwl/cwl#v1.0": "v1.0", "https://w3id.org/cwl/cwl#v1.0.dev4": "v1.0.dev4", "https://w3id.org/cwl/cwl#v1.1": "v1.1", @@ -16189,10 +25105,112 @@ def save( """ The **Any** type validates for any non-null value. """ -RecordFieldLoader = _RecordLoader(RecordField) -RecordSchemaLoader = _RecordLoader(RecordSchema) -EnumSchemaLoader = _RecordLoader(EnumSchema) -ArraySchemaLoader = _RecordLoader(ArraySchema) +RecordFieldLoader = _RecordLoader(RecordField, None, None) +RecordSchemaLoader = _RecordLoader(RecordSchema, None, None) +EnumSchemaLoader = _RecordLoader(EnumSchema, None, None) +ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) +MapSchemaLoader = _RecordLoader(MapSchema, None, None) +UnionSchemaLoader = _RecordLoader(UnionSchema, None, None) +CWLTypeLoader = _EnumLoader( + ( + "null", + "boolean", + "int", + "long", + "float", + "double", + "string", + "File", + "Directory", + ), + "CWLType", +) +""" +Extends primitive types with the concept of a file and directory as a builtin type. +File: A File object +Directory: A Directory object +""" +CWLArraySchemaLoader = _RecordLoader(CWLArraySchema, None, None) +CWLRecordFieldLoader = _RecordLoader(CWLRecordField, None, None) +CWLRecordSchemaLoader = _RecordLoader(CWLRecordSchema, None, None) +FileLoader = _RecordLoader(File, None, None) +DirectoryLoader = _RecordLoader(Directory, None, None) +CWLObjectTypeLoader = _UnionLoader((), "CWLObjectTypeLoader") +union_of_None_type_or_CWLObjectTypeLoader = _UnionLoader( + ( + None_type, + CWLObjectTypeLoader, + ) +) +array_of_union_of_None_type_or_CWLObjectTypeLoader = _ArrayLoader( + union_of_None_type_or_CWLObjectTypeLoader +) +map_of_union_of_None_type_or_CWLObjectTypeLoader = _MapLoader( + union_of_None_type_or_CWLObjectTypeLoader, "None", None, None +) +InlineJavascriptRequirementLoader = _RecordLoader( + InlineJavascriptRequirement, None, None +) +SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement, None, None) +LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement, None, None) +DockerRequirementLoader = _RecordLoader(DockerRequirement, None, None) +SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement, None, None) +InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement, None, None) +EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement, None, None) +ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement, None, None) +ResourceRequirementLoader = _RecordLoader(ResourceRequirement, None, None) +WorkReuseLoader = _RecordLoader(WorkReuse, None, None) +NetworkAccessLoader = _RecordLoader(NetworkAccess, None, None) +InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement, None, None) +ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit, None, None) +SubworkflowFeatureRequirementLoader = _RecordLoader( + SubworkflowFeatureRequirement, None, None +) +ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement, None, None) +MultipleInputFeatureRequirementLoader = _RecordLoader( + MultipleInputFeatureRequirement, None, None +) +StepInputExpressionRequirementLoader = _RecordLoader( + StepInputExpressionRequirement, None, None +) +union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( + ( + InlineJavascriptRequirementLoader, + SchemaDefRequirementLoader, + LoadListingRequirementLoader, + DockerRequirementLoader, + SoftwareRequirementLoader, + InitialWorkDirRequirementLoader, + EnvVarRequirementLoader, + ShellCommandRequirementLoader, + ResourceRequirementLoader, + WorkReuseLoader, + NetworkAccessLoader, + InplaceUpdateRequirementLoader, + ToolTimeLimitLoader, + SubworkflowFeatureRequirementLoader, + ScatterFeatureRequirementLoader, + MultipleInputFeatureRequirementLoader, + StepInputExpressionRequirementLoader, + ) +) +array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _ArrayLoader( + union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader +) +union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader = _UnionLoader( + ( + None_type, + array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader, + CWLObjectTypeLoader, + ) +) +map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader = _MapLoader( + union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader, + "CWLInputFile", + "@list", + True, +) +CWLInputFileLoader = map_of_union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader_or_CWLObjectTypeLoader CWLVersionLoader = _EnumLoader( ( "draft-2", @@ -16221,27 +25239,6 @@ def save( """ Version symbols for published CWL document versions. """ -CWLTypeLoader = _EnumLoader( - ( - "null", - "boolean", - "int", - "long", - "float", - "double", - "string", - "File", - "Directory", - ), - "CWLType", -) -""" -Extends primitive types with the concept of a file and directory as a builtin type. -File: A File object -Directory: A Directory object -""" -FileLoader = _RecordLoader(File) -DirectoryLoader = _RecordLoader(Directory) LoadListingEnumLoader = _EnumLoader( ( "no_listing", @@ -16259,33 +25256,30 @@ def save( deep_listing: Load the directory listing and recursively load all subdirectories as well. """ ExpressionLoader = _ExpressionLoader(str) -InputBindingLoader = _RecordLoader(InputBinding) -InputRecordFieldLoader = _RecordLoader(InputRecordField) -InputRecordSchemaLoader = _RecordLoader(InputRecordSchema) -InputEnumSchemaLoader = _RecordLoader(InputEnumSchema) -InputArraySchemaLoader = _RecordLoader(InputArraySchema) -OutputRecordFieldLoader = _RecordLoader(OutputRecordField) -OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema) -OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema) -OutputArraySchemaLoader = _RecordLoader(OutputArraySchema) -InlineJavascriptRequirementLoader = _RecordLoader(InlineJavascriptRequirement) -SchemaDefRequirementLoader = _RecordLoader(SchemaDefRequirement) -SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema) -LoadListingRequirementLoader = _RecordLoader(LoadListingRequirement) -EnvironmentDefLoader = _RecordLoader(EnvironmentDef) -CommandLineBindingLoader = _RecordLoader(CommandLineBinding) -CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding) -CommandLineBindableLoader = _RecordLoader(CommandLineBindable) -CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField) -CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema) -CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema) -CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema) -CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField) -CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema) -CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema) -CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema) -CommandInputParameterLoader = _RecordLoader(CommandInputParameter) -CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter) +InputBindingLoader = _RecordLoader(InputBinding, None, None) +InputRecordFieldLoader = _RecordLoader(InputRecordField, None, None) +InputRecordSchemaLoader = _RecordLoader(InputRecordSchema, None, None) +InputEnumSchemaLoader = _RecordLoader(InputEnumSchema, None, None) +InputArraySchemaLoader = _RecordLoader(InputArraySchema, None, None) +OutputRecordFieldLoader = _RecordLoader(OutputRecordField, None, None) +OutputRecordSchemaLoader = _RecordLoader(OutputRecordSchema, None, None) +OutputEnumSchemaLoader = _RecordLoader(OutputEnumSchema, None, None) +OutputArraySchemaLoader = _RecordLoader(OutputArraySchema, None, None) +SecondaryFileSchemaLoader = _RecordLoader(SecondaryFileSchema, None, None) +EnvironmentDefLoader = _RecordLoader(EnvironmentDef, None, None) +CommandLineBindingLoader = _RecordLoader(CommandLineBinding, None, None) +CommandOutputBindingLoader = _RecordLoader(CommandOutputBinding, None, None) +CommandLineBindableLoader = _RecordLoader(CommandLineBindable, None, None) +CommandInputRecordFieldLoader = _RecordLoader(CommandInputRecordField, None, None) +CommandInputRecordSchemaLoader = _RecordLoader(CommandInputRecordSchema, None, None) +CommandInputEnumSchemaLoader = _RecordLoader(CommandInputEnumSchema, None, None) +CommandInputArraySchemaLoader = _RecordLoader(CommandInputArraySchema, None, None) +CommandOutputRecordFieldLoader = _RecordLoader(CommandOutputRecordField, None, None) +CommandOutputRecordSchemaLoader = _RecordLoader(CommandOutputRecordSchema, None, None) +CommandOutputEnumSchemaLoader = _RecordLoader(CommandOutputEnumSchema, None, None) +CommandOutputArraySchemaLoader = _RecordLoader(CommandOutputArraySchema, None, None) +CommandInputParameterLoader = _RecordLoader(CommandInputParameter, None, None) +CommandOutputParameterLoader = _RecordLoader(CommandOutputParameter, None, None) stdinLoader = _EnumLoader(("stdin",), "stdin") """ Only valid as a `type` for a `CommandLineTool` input with no @@ -16400,22 +25394,14 @@ def save( stderr: random_stderr_filenameABCDEFG ``` """ -CommandLineToolLoader = _RecordLoader(CommandLineTool) -DockerRequirementLoader = _RecordLoader(DockerRequirement) -SoftwareRequirementLoader = _RecordLoader(SoftwareRequirement) -SoftwarePackageLoader = _RecordLoader(SoftwarePackage) -DirentLoader = _RecordLoader(Dirent) -InitialWorkDirRequirementLoader = _RecordLoader(InitialWorkDirRequirement) -EnvVarRequirementLoader = _RecordLoader(EnvVarRequirement) -ShellCommandRequirementLoader = _RecordLoader(ShellCommandRequirement) -ResourceRequirementLoader = _RecordLoader(ResourceRequirement) -WorkReuseLoader = _RecordLoader(WorkReuse) -NetworkAccessLoader = _RecordLoader(NetworkAccess) -InplaceUpdateRequirementLoader = _RecordLoader(InplaceUpdateRequirement) -ToolTimeLimitLoader = _RecordLoader(ToolTimeLimit) -ExpressionToolOutputParameterLoader = _RecordLoader(ExpressionToolOutputParameter) -WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter) -ExpressionToolLoader = _RecordLoader(ExpressionTool) +CommandLineToolLoader = _RecordLoader(CommandLineTool, None, None) +SoftwarePackageLoader = _RecordLoader(SoftwarePackage, None, None) +DirentLoader = _RecordLoader(Dirent, None, None) +ExpressionToolOutputParameterLoader = _RecordLoader( + ExpressionToolOutputParameter, None, None +) +WorkflowInputParameterLoader = _RecordLoader(WorkflowInputParameter, None, None) +ExpressionToolLoader = _RecordLoader(ExpressionTool, None, None) LinkMergeMethodLoader = _EnumLoader( ( "merge_nested", @@ -16437,9 +25423,9 @@ def save( """ Picking non-null values among inbound data links, described in [WorkflowStepInput](#WorkflowStepInput). """ -WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter) -WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput) -WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput) +WorkflowOutputParameterLoader = _RecordLoader(WorkflowOutputParameter, None, None) +WorkflowStepInputLoader = _RecordLoader(WorkflowStepInput, None, None) +WorkflowStepOutputLoader = _RecordLoader(WorkflowStepOutput, None, None) ScatterMethodLoader = _EnumLoader( ( "dotproduct", @@ -16451,15 +25437,11 @@ def save( """ The scatter method, as described in [workflow step scatter](#WorkflowStep). """ -WorkflowStepLoader = _RecordLoader(WorkflowStep) -WorkflowLoader = _RecordLoader(Workflow) -SubworkflowFeatureRequirementLoader = _RecordLoader(SubworkflowFeatureRequirement) -ScatterFeatureRequirementLoader = _RecordLoader(ScatterFeatureRequirement) -MultipleInputFeatureRequirementLoader = _RecordLoader(MultipleInputFeatureRequirement) -StepInputExpressionRequirementLoader = _RecordLoader(StepInputExpressionRequirement) -OperationInputParameterLoader = _RecordLoader(OperationInputParameter) -OperationOutputParameterLoader = _RecordLoader(OperationOutputParameter) -OperationLoader = _RecordLoader(Operation) +WorkflowStepLoader = _RecordLoader(WorkflowStep, None, None) +WorkflowLoader = _RecordLoader(Workflow, None, None) +OperationInputParameterLoader = _RecordLoader(OperationInputParameter, None, None) +OperationOutputParameterLoader = _RecordLoader(OperationOutputParameter, None, None) +OperationLoader = _RecordLoader(Operation, None, None) array_of_strtype = _ArrayLoader(strtype) union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( ( @@ -16468,31 +25450,35 @@ def save( array_of_strtype, ) ) -uri_strtype_True_False_None = _URILoader(strtype, True, False, None) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +uri_strtype_True_False_None_None = _URILoader(strtype, True, False, None, None) +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, ) ) -array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _ArrayLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype +array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype ) -union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype = _UnionLoader( +union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype = _UnionLoader( ( PrimitiveTypeLoader, RecordSchemaLoader, EnumSchemaLoader, ArraySchemaLoader, + MapSchemaLoader, + UnionSchemaLoader, strtype, - array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, + array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, ) ) -typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, +typedsl_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, 2, "v1.1", ) @@ -16514,24 +25500,77 @@ def save( strtype, ) ) -uri_union_of_None_type_or_strtype_True_False_None = _URILoader( - union_of_None_type_or_strtype, True, False, None +uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( + union_of_None_type_or_strtype, True, False, None, None +) +uri_array_of_strtype_True_False_None_None = _URILoader( + array_of_strtype, True, False, None, None ) -uri_array_of_strtype_True_False_None = _URILoader(array_of_strtype, True, False, None) Enum_nameLoader = _EnumLoader(("enum",), "Enum_name") typedsl_Enum_nameLoader_2 = _TypeDSLLoader(Enum_nameLoader, 2, "v1.1") -uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_False_True_2 = _URILoader( - union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_strtype, +uri_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_RecordSchemaLoader_or_EnumSchemaLoader_or_ArraySchemaLoader_or_MapSchemaLoader_or_UnionSchemaLoader_or_strtype, False, True, 2, + None, ) Array_nameLoader = _EnumLoader(("array",), "Array_name") typedsl_Array_nameLoader_2 = _TypeDSLLoader(Array_nameLoader, 2, "v1.1") +Map_nameLoader = _EnumLoader(("map",), "Map_name") +typedsl_Map_nameLoader_2 = _TypeDSLLoader(Map_nameLoader, 2, "v1.1") +Union_nameLoader = _EnumLoader(("union",), "Union_name") +typedsl_Union_nameLoader_2 = _TypeDSLLoader(Union_nameLoader, 2, "v1.1") +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + ) +) +array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _ArrayLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype +) +union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype = _UnionLoader( + ( + PrimitiveTypeLoader, + CWLRecordSchemaLoader, + EnumSchemaLoader, + CWLArraySchemaLoader, + strtype, + array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + ) +) +uri_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + False, + True, + 2, + None, +) +typedsl_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_2 = _TypeDSLLoader( + union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype_or_array_of_union_of_PrimitiveTypeLoader_or_CWLRecordSchemaLoader_or_EnumSchemaLoader_or_CWLArraySchemaLoader_or_strtype, + 2, + "v1.1", +) +array_of_CWLRecordFieldLoader = _ArrayLoader(CWLRecordFieldLoader) +union_of_None_type_or_array_of_CWLRecordFieldLoader = _UnionLoader( + ( + None_type, + array_of_CWLRecordFieldLoader, + ) +) +idmap_fields_union_of_None_type_or_array_of_CWLRecordFieldLoader = _IdMapLoader( + union_of_None_type_or_array_of_CWLRecordFieldLoader, "name", "type" +) File_classLoader = _EnumLoader(("File",), "File_class") -uri_File_classLoader_False_True_None = _URILoader(File_classLoader, False, True, None) -uri_union_of_None_type_or_strtype_False_False_None = _URILoader( - union_of_None_type_or_strtype, False, False, None +uri_File_classLoader_False_True_None_None = _URILoader( + File_classLoader, False, True, None, None +) +uri_union_of_None_type_or_strtype_False_False_None_None = _URILoader( + union_of_None_type_or_strtype, False, False, None, None ) union_of_None_type_or_inttype = _UnionLoader( ( @@ -16554,12 +25593,20 @@ def save( array_of_union_of_FileLoader_or_DirectoryLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _SecondaryDSLLoader( - union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader +secondaryfilesdsl_union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( + ( + _SecondaryDSLLoader( + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader + ), + union_of_None_type_or_array_of_union_of_FileLoader_or_DirectoryLoader, + ) +) +uri_union_of_None_type_or_strtype_True_False_None_True = _URILoader( + union_of_None_type_or_strtype, True, False, None, True ) Directory_classLoader = _EnumLoader(("Directory",), "Directory_class") -uri_Directory_classLoader_False_True_None = _URILoader( - Directory_classLoader, False, True, None +uri_Directory_classLoader_False_True_None_None = _URILoader( + Directory_classLoader, False, True, None, None ) union_of_None_type_or_booltype = _UnionLoader( ( @@ -16581,8 +25628,13 @@ def save( array_of_SecondaryFileSchemaLoader, ) ) -secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _SecondaryDSLLoader( - union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader +secondaryfilesdsl_union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader = _UnionLoader( + ( + _SecondaryDSLLoader( + union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader + ), + union_of_None_type_or_SecondaryFileSchemaLoader_or_array_of_SecondaryFileSchemaLoader, + ) ) union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -16592,11 +25644,12 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None = _URILoader( +uri_union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( union_of_None_type_or_strtype_or_array_of_strtype_or_ExpressionLoader, True, False, None, + True, ) union_of_None_type_or_strtype_or_ExpressionLoader = _UnionLoader( ( @@ -16605,8 +25658,8 @@ def save( ExpressionLoader, ) ) -uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None = _URILoader( - union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None +uri_union_of_None_type_or_strtype_or_ExpressionLoader_True_False_None_True = _URILoader( + union_of_None_type_or_strtype_or_ExpressionLoader, True, False, None, True ) union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -16645,11 +25698,12 @@ def save( idmap_fields_union_of_None_type_or_array_of_InputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_InputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2 = _URILoader( +uri_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_InputRecordSchemaLoader_or_InputEnumSchemaLoader_or_InputArraySchemaLoader_or_strtype, False, True, 2, + None, ) union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -16688,19 +25742,12 @@ def save( idmap_fields_union_of_None_type_or_array_of_OutputRecordFieldLoader = _IdMapLoader( union_of_None_type_or_array_of_OutputRecordFieldLoader, "name", "type" ) -uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2 = _URILoader( +uri_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_OutputRecordSchemaLoader_or_OutputEnumSchemaLoader_or_OutputArraySchemaLoader_or_strtype, False, True, 2, -) -union_of_None_type_or_FileLoader_or_DirectoryLoader_or_Any_type = _UnionLoader( - ( - None_type, - FileLoader, - DirectoryLoader, - Any_type, - ) + None, ) union_of_CommandInputParameterLoader_or_WorkflowInputParameterLoader_or_OperationInputParameterLoader = _UnionLoader( ( @@ -16733,30 +25780,6 @@ def save( "id", "type", ) -union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( - ( - InlineJavascriptRequirementLoader, - SchemaDefRequirementLoader, - LoadListingRequirementLoader, - DockerRequirementLoader, - SoftwareRequirementLoader, - InitialWorkDirRequirementLoader, - EnvVarRequirementLoader, - ShellCommandRequirementLoader, - ResourceRequirementLoader, - WorkReuseLoader, - NetworkAccessLoader, - InplaceUpdateRequirementLoader, - ToolTimeLimitLoader, - SubworkflowFeatureRequirementLoader, - ScatterFeatureRequirementLoader, - MultipleInputFeatureRequirementLoader, - StepInputExpressionRequirementLoader, - ) -) -array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _ArrayLoader( - union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader -) union_of_None_type_or_array_of_union_of_InlineJavascriptRequirementLoader_or_SchemaDefRequirementLoader_or_LoadListingRequirementLoader_or_DockerRequirementLoader_or_SoftwareRequirementLoader_or_InitialWorkDirRequirementLoader_or_EnvVarRequirementLoader_or_ShellCommandRequirementLoader_or_ResourceRequirementLoader_or_WorkReuseLoader_or_NetworkAccessLoader_or_InplaceUpdateRequirementLoader_or_ToolTimeLimitLoader_or_SubworkflowFeatureRequirementLoader_or_ScatterFeatureRequirementLoader_or_MultipleInputFeatureRequirementLoader_or_StepInputExpressionRequirementLoader = _UnionLoader( ( None_type, @@ -16810,8 +25833,8 @@ def save( CWLVersionLoader, ) ) -uri_union_of_None_type_or_CWLVersionLoader_False_True_None = _URILoader( - union_of_None_type_or_CWLVersionLoader, False, True, None +uri_union_of_None_type_or_CWLVersionLoader_False_True_None_None = _URILoader( + union_of_None_type_or_CWLVersionLoader, False, True, None, None ) union_of_None_type_or_array_of_strtype = _UnionLoader( ( @@ -16819,20 +25842,20 @@ def save( array_of_strtype, ) ) -uri_union_of_None_type_or_array_of_strtype_True_False_None = _URILoader( - union_of_None_type_or_array_of_strtype, True, False, None +uri_union_of_None_type_or_array_of_strtype_True_False_None_None = _URILoader( + union_of_None_type_or_array_of_strtype, True, False, None, None ) InlineJavascriptRequirement_classLoader = _EnumLoader( ("InlineJavascriptRequirement",), "InlineJavascriptRequirement_class" ) -uri_InlineJavascriptRequirement_classLoader_False_True_None = _URILoader( - InlineJavascriptRequirement_classLoader, False, True, None +uri_InlineJavascriptRequirement_classLoader_False_True_None_None = _URILoader( + InlineJavascriptRequirement_classLoader, False, True, None, None ) SchemaDefRequirement_classLoader = _EnumLoader( ("SchemaDefRequirement",), "SchemaDefRequirement_class" ) -uri_SchemaDefRequirement_classLoader_False_True_None = _URILoader( - SchemaDefRequirement_classLoader, False, True, None +uri_SchemaDefRequirement_classLoader_False_True_None_None = _URILoader( + SchemaDefRequirement_classLoader, False, True, None, None ) union_of_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader = _UnionLoader( ( @@ -16860,8 +25883,8 @@ def save( LoadListingRequirement_classLoader = _EnumLoader( ("LoadListingRequirement",), "LoadListingRequirement_class" ) -uri_LoadListingRequirement_classLoader_False_True_None = _URILoader( - LoadListingRequirement_classLoader, False, True, None +uri_LoadListingRequirement_classLoader_False_True_None_None = _URILoader( + LoadListingRequirement_classLoader, False, True, None, None ) union_of_None_type_or_inttype_or_ExpressionLoader = _UnionLoader( ( @@ -16929,11 +25952,12 @@ def save( union_of_None_type_or_array_of_CommandInputRecordFieldLoader, "name", "type" ) ) -uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2 = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype, False, True, 2, + None, ) union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -16980,11 +26004,12 @@ def save( union_of_None_type_or_array_of_CommandOutputRecordFieldLoader, "name", "type" ) ) -uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2 = _URILoader( +uri_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_False_True_2_None = _URILoader( union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandOutputRecordSchemaLoader_or_CommandOutputEnumSchemaLoader_or_CommandOutputArraySchemaLoader_or_strtype, False, True, 2, + None, ) union_of_CWLTypeLoader_or_stdinLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype_or_array_of_union_of_CWLTypeLoader_or_CommandInputRecordSchemaLoader_or_CommandInputEnumSchemaLoader_or_CommandInputArraySchemaLoader_or_strtype = _UnionLoader( ( @@ -17020,8 +26045,8 @@ def save( "v1.1", ) CommandLineTool_classLoader = _EnumLoader(("CommandLineTool",), "CommandLineTool_class") -uri_CommandLineTool_classLoader_False_True_None = _URILoader( - CommandLineTool_classLoader, False, True, None +uri_CommandLineTool_classLoader_False_True_None_None = _URILoader( + CommandLineTool_classLoader, False, True, None, None ) array_of_CommandInputParameterLoader = _ArrayLoader(CommandInputParameterLoader) idmap_inputs_array_of_CommandInputParameterLoader = _IdMapLoader( @@ -17057,27 +26082,27 @@ def save( DockerRequirement_classLoader = _EnumLoader( ("DockerRequirement",), "DockerRequirement_class" ) -uri_DockerRequirement_classLoader_False_True_None = _URILoader( - DockerRequirement_classLoader, False, True, None +uri_DockerRequirement_classLoader_False_True_None_None = _URILoader( + DockerRequirement_classLoader, False, True, None, None ) SoftwareRequirement_classLoader = _EnumLoader( ("SoftwareRequirement",), "SoftwareRequirement_class" ) -uri_SoftwareRequirement_classLoader_False_True_None = _URILoader( - SoftwareRequirement_classLoader, False, True, None +uri_SoftwareRequirement_classLoader_False_True_None_None = _URILoader( + SoftwareRequirement_classLoader, False, True, None, None ) array_of_SoftwarePackageLoader = _ArrayLoader(SoftwarePackageLoader) idmap_packages_array_of_SoftwarePackageLoader = _IdMapLoader( array_of_SoftwarePackageLoader, "package", "specs" ) -uri_union_of_None_type_or_array_of_strtype_False_False_None = _URILoader( - union_of_None_type_or_array_of_strtype, False, False, None +uri_union_of_None_type_or_array_of_strtype_False_False_None_True = _URILoader( + union_of_None_type_or_array_of_strtype, False, False, None, True ) InitialWorkDirRequirement_classLoader = _EnumLoader( ("InitialWorkDirRequirement",), "InitialWorkDirRequirement_class" ) -uri_InitialWorkDirRequirement_classLoader_False_True_None = _URILoader( - InitialWorkDirRequirement_classLoader, False, True, None +uri_InitialWorkDirRequirement_classLoader_False_True_None_None = _URILoader( + InitialWorkDirRequirement_classLoader, False, True, None, None ) union_of_None_type_or_DirentLoader_or_ExpressionLoader_or_FileLoader_or_DirectoryLoader_or_array_of_union_of_FileLoader_or_DirectoryLoader = _UnionLoader( ( @@ -17101,8 +26126,8 @@ def save( EnvVarRequirement_classLoader = _EnumLoader( ("EnvVarRequirement",), "EnvVarRequirement_class" ) -uri_EnvVarRequirement_classLoader_False_True_None = _URILoader( - EnvVarRequirement_classLoader, False, True, None +uri_EnvVarRequirement_classLoader_False_True_None_None = _URILoader( + EnvVarRequirement_classLoader, False, True, None, None ) array_of_EnvironmentDefLoader = _ArrayLoader(EnvironmentDefLoader) idmap_envDef_array_of_EnvironmentDefLoader = _IdMapLoader( @@ -17111,14 +26136,14 @@ def save( ShellCommandRequirement_classLoader = _EnumLoader( ("ShellCommandRequirement",), "ShellCommandRequirement_class" ) -uri_ShellCommandRequirement_classLoader_False_True_None = _URILoader( - ShellCommandRequirement_classLoader, False, True, None +uri_ShellCommandRequirement_classLoader_False_True_None_None = _URILoader( + ShellCommandRequirement_classLoader, False, True, None, None ) ResourceRequirement_classLoader = _EnumLoader( ("ResourceRequirement",), "ResourceRequirement_class" ) -uri_ResourceRequirement_classLoader_False_True_None = _URILoader( - ResourceRequirement_classLoader, False, True, None +uri_ResourceRequirement_classLoader_False_True_None_None = _URILoader( + ResourceRequirement_classLoader, False, True, None, None ) union_of_None_type_or_inttype_or_floattype_or_ExpressionLoader = _UnionLoader( ( @@ -17129,8 +26154,8 @@ def save( ) ) WorkReuse_classLoader = _EnumLoader(("WorkReuse",), "WorkReuse_class") -uri_WorkReuse_classLoader_False_True_None = _URILoader( - WorkReuse_classLoader, False, True, None +uri_WorkReuse_classLoader_False_True_None_None = _URILoader( + WorkReuse_classLoader, False, True, None, None ) union_of_booltype_or_ExpressionLoader = _UnionLoader( ( @@ -17139,18 +26164,18 @@ def save( ) ) NetworkAccess_classLoader = _EnumLoader(("NetworkAccess",), "NetworkAccess_class") -uri_NetworkAccess_classLoader_False_True_None = _URILoader( - NetworkAccess_classLoader, False, True, None +uri_NetworkAccess_classLoader_False_True_None_None = _URILoader( + NetworkAccess_classLoader, False, True, None, None ) InplaceUpdateRequirement_classLoader = _EnumLoader( ("InplaceUpdateRequirement",), "InplaceUpdateRequirement_class" ) -uri_InplaceUpdateRequirement_classLoader_False_True_None = _URILoader( - InplaceUpdateRequirement_classLoader, False, True, None +uri_InplaceUpdateRequirement_classLoader_False_True_None_None = _URILoader( + InplaceUpdateRequirement_classLoader, False, True, None, None ) ToolTimeLimit_classLoader = _EnumLoader(("ToolTimeLimit",), "ToolTimeLimit_class") -uri_ToolTimeLimit_classLoader_False_True_None = _URILoader( - ToolTimeLimit_classLoader, False, True, None +uri_ToolTimeLimit_classLoader_False_True_None_None = _URILoader( + ToolTimeLimit_classLoader, False, True, None, None ) union_of_inttype_or_ExpressionLoader = _UnionLoader( ( @@ -17165,8 +26190,8 @@ def save( ) ) ExpressionTool_classLoader = _EnumLoader(("ExpressionTool",), "ExpressionTool_class") -uri_ExpressionTool_classLoader_False_True_None = _URILoader( - ExpressionTool_classLoader, False, True, None +uri_ExpressionTool_classLoader_False_True_None_None = _URILoader( + ExpressionTool_classLoader, False, True, None, None ) array_of_WorkflowInputParameterLoader = _ArrayLoader(WorkflowInputParameterLoader) idmap_inputs_array_of_WorkflowInputParameterLoader = _IdMapLoader( @@ -17178,8 +26203,8 @@ def save( idmap_outputs_array_of_ExpressionToolOutputParameterLoader = _IdMapLoader( array_of_ExpressionToolOutputParameterLoader, "id", "type" ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_1_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 1, None ) union_of_None_type_or_LinkMergeMethodLoader = _UnionLoader( ( @@ -17193,8 +26218,8 @@ def save( PickValueMethodLoader, ) ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 2, None ) array_of_WorkflowStepInputLoader = _ArrayLoader(WorkflowStepInputLoader) idmap_in__array_of_WorkflowStepInputLoader = _IdMapLoader( @@ -17212,13 +26237,12 @@ def save( union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader = _UnionLoader( (array_of_union_of_strtype_or_WorkflowStepOutputLoader,) ) -uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None = ( - _URILoader( - union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, - True, - False, - None, - ) +uri_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_True_False_None_None = _URILoader( + union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader, + True, + False, + None, + None, ) array_of_Any_type = _ArrayLoader(Any_type) union_of_None_type_or_array_of_Any_type = _UnionLoader( @@ -17239,14 +26263,15 @@ def save( OperationLoader, ) ) -uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None = _URILoader( +uri_union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader_False_False_None_None = _URILoader( union_of_strtype_or_CommandLineToolLoader_or_ExpressionToolLoader_or_WorkflowLoader_or_OperationLoader, False, False, None, + None, ) -uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0 = _URILoader( - union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0 +uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_0_None = _URILoader( + union_of_None_type_or_strtype_or_array_of_strtype, False, False, 0, None ) union_of_None_type_or_ScatterMethodLoader = _UnionLoader( ( @@ -17254,12 +26279,12 @@ def save( ScatterMethodLoader, ) ) -uri_union_of_None_type_or_ScatterMethodLoader_False_True_None = _URILoader( - union_of_None_type_or_ScatterMethodLoader, False, True, None +uri_union_of_None_type_or_ScatterMethodLoader_False_True_None_None = _URILoader( + union_of_None_type_or_ScatterMethodLoader, False, True, None, None ) Workflow_classLoader = _EnumLoader(("Workflow",), "Workflow_class") -uri_Workflow_classLoader_False_True_None = _URILoader( - Workflow_classLoader, False, True, None +uri_Workflow_classLoader_False_True_None_None = _URILoader( + Workflow_classLoader, False, True, None, None ) array_of_WorkflowOutputParameterLoader = _ArrayLoader(WorkflowOutputParameterLoader) idmap_outputs_array_of_WorkflowOutputParameterLoader = _IdMapLoader( @@ -17273,30 +26298,30 @@ def save( SubworkflowFeatureRequirement_classLoader = _EnumLoader( ("SubworkflowFeatureRequirement",), "SubworkflowFeatureRequirement_class" ) -uri_SubworkflowFeatureRequirement_classLoader_False_True_None = _URILoader( - SubworkflowFeatureRequirement_classLoader, False, True, None +uri_SubworkflowFeatureRequirement_classLoader_False_True_None_None = _URILoader( + SubworkflowFeatureRequirement_classLoader, False, True, None, None ) ScatterFeatureRequirement_classLoader = _EnumLoader( ("ScatterFeatureRequirement",), "ScatterFeatureRequirement_class" ) -uri_ScatterFeatureRequirement_classLoader_False_True_None = _URILoader( - ScatterFeatureRequirement_classLoader, False, True, None +uri_ScatterFeatureRequirement_classLoader_False_True_None_None = _URILoader( + ScatterFeatureRequirement_classLoader, False, True, None, None ) MultipleInputFeatureRequirement_classLoader = _EnumLoader( ("MultipleInputFeatureRequirement",), "MultipleInputFeatureRequirement_class" ) -uri_MultipleInputFeatureRequirement_classLoader_False_True_None = _URILoader( - MultipleInputFeatureRequirement_classLoader, False, True, None +uri_MultipleInputFeatureRequirement_classLoader_False_True_None_None = _URILoader( + MultipleInputFeatureRequirement_classLoader, False, True, None, None ) StepInputExpressionRequirement_classLoader = _EnumLoader( ("StepInputExpressionRequirement",), "StepInputExpressionRequirement_class" ) -uri_StepInputExpressionRequirement_classLoader_False_True_None = _URILoader( - StepInputExpressionRequirement_classLoader, False, True, None +uri_StepInputExpressionRequirement_classLoader_False_True_None_None = _URILoader( + StepInputExpressionRequirement_classLoader, False, True, None, None ) Operation_classLoader = _EnumLoader(("Operation",), "Operation_class") -uri_Operation_classLoader_False_True_None = _URILoader( - Operation_classLoader, False, True, None +uri_Operation_classLoader_False_True_None_None = _URILoader( + Operation_classLoader, False, True, None, None ) array_of_OperationInputParameterLoader = _ArrayLoader(OperationInputParameterLoader) idmap_inputs_array_of_OperationInputParameterLoader = _IdMapLoader( @@ -17327,6 +26352,19 @@ def save( ) ) +CWLObjectTypeLoader.add_loaders( + ( + booltype, + inttype, + floattype, + strtype, + FileLoader, + DirectoryLoader, + array_of_union_of_None_type_or_CWLObjectTypeLoader, + map_of_union_of_None_type_or_CWLObjectTypeLoader, + ) +) + def load_document( doc: Any, diff --git a/cwl_utils/parser/cwl_v1_2_utils.py b/cwl_utils/parser/cwl_v1_2_utils.py index 0e3e17f5..b58f3f40 100644 --- a/cwl_utils/parser/cwl_v1_2_utils.py +++ b/cwl_utils/parser/cwl_v1_2_utils.py @@ -1,13 +1,27 @@ # SPDX-License-Identifier: Apache-2.0 import hashlib import logging +import os from collections import namedtuple -from typing import IO, Any, Dict, List, MutableSequence, Optional, Tuple, Union, cast +from io import StringIO +from typing import ( + Any, + Dict, + IO, + List, + MutableMapping, + MutableSequence, + Optional, + Tuple, + Union, + cast, +) +from urllib.parse import urldefrag from ruamel import yaml from schema_salad.exceptions import ValidationException -from schema_salad.sourceline import SourceLine -from schema_salad.utils import aslist, json_dumps +from schema_salad.sourceline import SourceLine, add_lc_filename +from schema_salad.utils import aslist, json_dumps, yaml_no_ts import cwl_utils.parser import cwl_utils.parser.cwl_v1_2 as cwl @@ -30,9 +44,9 @@ def _compare_records( This handles normalizing record names, which will be relative to workflow step, so that they can be compared. """ - srcfields = {cwl.shortname(field.name): field.type for field in (src.fields or {})} + srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})} sinkfields = { - cwl.shortname(field.name): field.type for field in (sink.fields or {}) + cwl.shortname(field.name): field.type_ for field in (sink.fields or {}) } for key in sinkfields.keys(): if ( @@ -63,10 +77,10 @@ def _compare_type(type1: Any, type2: Any) -> bool: return _compare_type(type1.items, type2.items) elif isinstance(type1, cwl.RecordSchema) and isinstance(type2, cwl.RecordSchema): fields1 = { - cwl.shortname(field.name): field.type for field in (type1.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type1.fields or {}) } fields2 = { - cwl.shortname(field.name): field.type for field in (type2.fields or {}) + cwl.shortname(field.name): field.type_ for field in (type2.fields or {}) } if fields1.keys() != fields2.keys(): return False @@ -91,6 +105,64 @@ def _is_conditional_step( return False +def _inputfile_load( + doc: Union[str, MutableMapping[str, Any], MutableSequence[Any]], + baseuri: str, + loadingOptions: cwl.LoadingOptions, + addl_metadata_fields: Optional[MutableSequence[str]] = None, +) -> Tuple[Any, cwl.LoadingOptions]: + loader = cwl.CWLInputFileLoader + if isinstance(doc, str): + url = loadingOptions.fetcher.urljoin(baseuri, doc) + if url in loadingOptions.idx: + return loadingOptions.idx[url] + doc_url, frg = urldefrag(url) + text = loadingOptions.fetcher.fetch_text(doc_url) + textIO = StringIO(text) + textIO.name = str(doc_url) + yaml = yaml_no_ts() + result = yaml.load(textIO) + add_lc_filename(result, doc_url) + loadingOptions = cwl.LoadingOptions(copyfrom=loadingOptions, fileuri=doc_url) + _inputfile_load( + result, + doc_url, + loadingOptions, + ) + return loadingOptions.idx[url] + + if isinstance(doc, MutableMapping): + addl_metadata = {} + if addl_metadata_fields is not None: + for mf in addl_metadata_fields: + if mf in doc: + addl_metadata[mf] = doc[mf] + + loadingOptions = cwl.LoadingOptions( + copyfrom=loadingOptions, + baseuri=baseuri, + addl_metadata=addl_metadata, + ) + + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions, docRoot=baseuri), + loadingOptions, + ) + + return loadingOptions.idx[baseuri] + + if isinstance(doc, MutableSequence): + loadingOptions.idx[baseuri] = ( + loader.load(doc, baseuri, loadingOptions), + loadingOptions, + ) + return loadingOptions.idx[baseuri] + + raise ValidationException( + "Expected URI string, MutableMapping or MutableSequence, got %s" % type(doc) + ) + + def can_assign_src_to_sink(src: Any, sink: Any, strict: bool = False) -> bool: """ Check for identical type specifications, ignoring extra keys like inputBinding. @@ -242,7 +314,7 @@ def check_types( return "exception" if linkMerge == "merge_nested": return check_types( - cwl.ArraySchema(items=srctype, type="array"), sinktype, None, None + cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None ) if linkMerge == "merge_flattened": return check_types(merge_flatten_type(srctype), sinktype, None, None) @@ -275,7 +347,7 @@ def content_limit_respected_read(f: IO[bytes]) -> str: def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: """Convert stdin, stdout and stderr type shortcuts to files.""" for out in clt.outputs: - if out.type == "stdout": + if out.type_ == "stdout": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stdout shortcut." @@ -286,9 +358,9 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stdout) - elif out.type == "stderr": + elif out.type_ == "stderr": if out.outputBinding is not None: raise ValidationException( "Not allowed to specify outputBinding when using stderr shortcut." @@ -299,10 +371,10 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: json_dumps(clt.save(), sort_keys=True).encode("utf-8") ).hexdigest() ) - out.type = "File" + out.type_ = "File" out.outputBinding = cwl.CommandOutputBinding(glob=clt.stderr) for inp in clt.inputs: - if inp.type == "stdin": + if inp.type_ == "stdin": if inp.inputBinding is not None: raise ValidationException( "Not allowed to specify unputBinding when using stdin shortcut." @@ -316,7 +388,65 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None: "$(inputs.%s.path)" % cast(str, inp.id).rpartition("#")[2].split("/")[-1] ) - inp.type = "File" + inp.type_ = "File" + + +def load_inputfile( + doc: Any, + baseuri: Optional[str] = None, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.2 input file from a serialized YAML string or a YAML object.""" + if baseuri is None: + baseuri = cwl.file_uri(os.getcwd()) + "/" + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions() + result, metadata = _inputfile_load( + doc, + baseuri, + loadingOptions, + ) + return result + + +def load_inputfile_by_string( + string: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.2 input file from a serialized YAML string.""" + yaml = yaml_no_ts() + result = yaml.load(string) + add_lc_filename(result, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + result, + uri, + loadingOptions, + ) + return result + + +def load_inputfile_by_yaml( + yaml: Any, + uri: str, + loadingOptions: Optional[cwl.LoadingOptions] = None, +) -> Any: + """Load a CWL v1.2 input file from a YAML object.""" + add_lc_filename(yaml, uri) + + if loadingOptions is None: + loadingOptions = cwl.LoadingOptions(fileuri=uri) + + result, metadata = _inputfile_load( + yaml, + uri, + loadingOptions, + ) + return result def merge_flatten_type(src: Any) -> Any: @@ -325,7 +455,7 @@ def merge_flatten_type(src: Any) -> Any: return [merge_flatten_type(t) for t in src] if isinstance(src, cwl.ArraySchema): return src - return cwl.ArraySchema(type="array", items=src) + return cwl.ArraySchema(type_="array", items=src) def type_for_step_input( @@ -343,9 +473,9 @@ def type_for_step_input( cast(str, step_input.id).split("#")[-1] == cast(str, in_.id).split("#")[-1] ): - input_type = step_input.type + input_type = step_input.type_ if step.scatter is not None and in_.id in aslist(step.scatter): - input_type = cwl.ArraySchema(items=input_type, type="array") + input_type = cwl.ArraySchema(items=input_type, type_="array") return input_type return "Any" @@ -363,15 +493,15 @@ def type_for_step_output( output.id.split("#")[-1].split("/")[-1] == sourcename.split("#")[-1].split("/")[-1] ): - output_type = output.type + output_type = output.type_ if step.scatter is not None: if step.scatterMethod == "nested_crossproduct": for _ in range(len(aslist(step.scatter))): output_type = cwl.ArraySchema( - items=output_type, type="array" + items=output_type, type_="array" ) else: - output_type = cwl.ArraySchema(items=output_type, type="array") + output_type = cwl.ArraySchema(items=output_type, type_="array") return output_type raise ValidationException( "param {} not found in {}.".format( @@ -392,15 +522,15 @@ def type_for_source( scatter_context: List[Optional[Tuple[int, str]]] = [] params = param_for_source_id(process, sourcenames, parent, scatter_context) if not isinstance(params, list): - new_type = params.type + new_type = params.type_ if scatter_context[0] is not None: if scatter_context[0][1] == "nested_crossproduct": for _ in range(scatter_context[0][0]): - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") else: - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": new_type = merge_flatten_type(new_type) if pickValue is not None: @@ -412,26 +542,28 @@ def type_for_source( for p, sc in zip(params, scatter_context): if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type): cur_type = p - elif hasattr(p, "type") and not any(_compare_type(t, p.type) for t in new_type): - cur_type = p.type + elif hasattr(p, "type_") and not any( + _compare_type(t, p.type_) for t in new_type + ): + cur_type = p.type_ else: cur_type = None if cur_type is not None: if sc is not None: if sc[1] == "nested_crossproduct": for _ in range(sc[0]): - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") else: - cur_type = cwl.ArraySchema(items=cur_type, type="array") + cur_type = cwl.ArraySchema(items=cur_type, type_="array") new_type.append(cur_type) if len(new_type) == 1: new_type = new_type[0] if linkMerge == "merge_nested": - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") elif linkMerge == "merge_flattened": new_type = merge_flatten_type(new_type) elif isinstance(sourcenames, List) and len(sourcenames) > 1: - new_type = cwl.ArraySchema(items=new_type, type="array") + new_type = cwl.ArraySchema(items=new_type, type_="array") if pickValue is not None: if isinstance(new_type, cwl.ArraySchema): if pickValue in ["first_non_null", "the_only_non_null"]: diff --git a/cwl_utils/parser/utils.py b/cwl_utils/parser/utils.py index 38a1b33d..8298a41e 100644 --- a/cwl_utils/parser/utils.py +++ b/cwl_utils/parser/utils.py @@ -1,16 +1,20 @@ """CWL parser utility functions.""" import copy import logging +import os +from pathlib import Path from types import ModuleType from typing import Any, Dict, List, MutableSequence, Optional, Tuple, Union, cast +from urllib.parse import unquote_plus, urlparse from schema_salad.exceptions import ValidationException from schema_salad.sourceline import SourceLine, strip_dup_lineno -from schema_salad.utils import json_dumps +from schema_salad.utils import json_dumps, yaml_no_ts import cwl_utils - +import cwl_utils.parser from . import ( + LoadingOptions, Process, Workflow, WorkflowStep, @@ -36,6 +40,97 @@ def convert_stdstreams_to_files(process: Process) -> None: cwl_v1_2_utils.convert_stdstreams_to_files(process) +def load_inputfile_by_uri( + version: str, + path: Union[str, Path], + loadingOptions: Optional[LoadingOptions] = None, +) -> Any: + """Load a CWL input file from a URI or a path.""" + if isinstance(path, str): + uri = urlparse(path) + if not uri.scheme or uri.scheme == "file": + real_path = Path(unquote_plus(uri.path)).resolve().as_uri() + else: + real_path = path + else: + real_path = path.resolve().as_uri() + + if version is None: + raise ValidationException("could not get the cwlVersion") + + baseuri = str(real_path) + + if loadingOptions is None: + if version == "v1.0": + loadingOptions = cwl_v1_0.LoadingOptions(fileuri=baseuri) + elif version == "v1.1": + loadingOptions = cwl_v1_1.LoadingOptions(fileuri=baseuri) + elif version == "v1.2": + loadingOptions = cwl_v1_2.LoadingOptions(fileuri=baseuri) + else: + raise ValidationException( + f"Version error. Did not recognise {version} as a CWL version" + ) + + doc = loadingOptions.fetcher.fetch_text(real_path) + return load_inputfile_by_string(version, doc, baseuri, loadingOptions) + + +def load_inputfile( + version: str, + doc: Any, + baseuri: Optional[str] = None, + loadingOptions: Optional[LoadingOptions] = None, +) -> Any: + """Load a CWL input file from a serialized YAML string or a YAML object.""" + if baseuri is None: + baseuri = cwl_v1_0.file_uri(os.getcwd()) + "/" + if isinstance(doc, str): + return load_inputfile_by_string(version, doc, baseuri, loadingOptions) + return load_inputfile_by_yaml(version, doc, baseuri, loadingOptions) + + +def load_inputfile_by_string( + version: str, + string: str, + uri: str, + loadingOptions: Optional[LoadingOptions] = None, +) -> Any: + """Load a CWL input file from a serialized YAML string.""" + yaml = yaml_no_ts() + result = yaml.load(string) + return load_inputfile_by_yaml(version, result, uri, loadingOptions) + + +def load_inputfile_by_yaml( + version: str, + yaml: Any, + uri: str, + loadingOptions: Optional[LoadingOptions] = None, +) -> Any: + """Load a CWL input file from a YAML object.""" + if version == "v1.0": + result = cwl_v1_0_utils.load_inputfile_by_yaml( + yaml, uri, cast(Optional[cwl_v1_0.LoadingOptions], loadingOptions) + ) + elif version == "v1.1": + result = cwl_v1_1_utils.load_inputfile_by_yaml( + yaml, uri, cast(Optional[cwl_v1_1.LoadingOptions], loadingOptions) + ) + elif version == "v1.2": + result = cwl_v1_2_utils.load_inputfile_by_yaml( + yaml, uri, cast(Optional[cwl_v1_2.LoadingOptions], loadingOptions) + ) + elif version is None: + raise ValidationException("could not get the cwlVersion") + else: + raise ValidationException( + f"Version error. Did not recognise {version} as a CWL version" + ) + + return result + + def load_step( step: cwl_utils.parser.WorkflowStep, ) -> Process: @@ -103,8 +198,8 @@ def static_checker(workflow: cwl_utils.parser.Workflow) -> None: } type_dict = { **type_dict, - **{param.id: param.type for param in workflow.inputs}, - **{param.id: param.type for param in workflow.outputs}, + **{param.id: param.type_ for param in workflow.inputs}, + **{param.id: param.type_ for param in workflow.outputs}, } parser: ModuleType diff --git a/requirements.txt b/requirements.txt index 02ead4a4..c167a0c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ cwl-upgrader >= 1.2.3 packaging rdflib requests -schema-salad >= 8.3.20220825114525, < 9 +schema-salad @ git+https://github.com/common-workflow-language/schema_salad.git@refs/pull/672/head ruamel.yaml >= 0.17.6, < 0.19 diff --git a/testdata/dir4-job.yml b/testdata/dir4-job.yml new file mode 100644 index 00000000..7cf6ce54 --- /dev/null +++ b/testdata/dir4-job.yml @@ -0,0 +1,9 @@ +inf: + class: File + location: hello.tar + secondaryFiles: + - class: File + location: index.py + - class: Directory + basename: xtestdir + location: testdir \ No newline at end of file diff --git a/testdata/env-job3.yaml b/testdata/env-job3.yaml new file mode 100644 index 00000000..579b9561 --- /dev/null +++ b/testdata/env-job3.yaml @@ -0,0 +1,6 @@ +in: "hello test env" +cwl:requirements: + - class: EnvVarRequirement + envDef: + - envName: TEST_ENV + envValue: $(inputs.in) diff --git a/testdata/formattest-job.json b/testdata/formattest-job.json new file mode 100644 index 00000000..0ff02409 --- /dev/null +++ b/testdata/formattest-job.json @@ -0,0 +1,7 @@ +{ + "input": { + "class": "File", + "location": "whale.txt", + "format": "edam:format_2330" + } +} diff --git a/testdata/nested-array-job.yml b/testdata/nested-array-job.yml new file mode 100644 index 00000000..5b82ec4a --- /dev/null +++ b/testdata/nested-array-job.yml @@ -0,0 +1 @@ +letters: [[a]] \ No newline at end of file diff --git a/tests/test_parser_utils.py b/tests/test_parser_utils.py index 1d12345e..075f6160 100644 --- a/tests/test_parser_utils.py +++ b/tests/test_parser_utils.py @@ -17,7 +17,6 @@ import cwl_utils.parser.utils from cwl_utils.errors import WorkflowException from cwl_utils.parser import load_document_by_uri - from .util import get_data @@ -134,12 +133,42 @@ def test_v1_0_file_content_larger_than_64_kB() -> None: assert content == text[0 : cwl_utils.parser.cwl_v1_0_utils.CONTENT_LIMIT] +def test_v_1_0_load_inputfile_with_format() -> None: + """Test that File object with the `format` field is correctly loaded with CWL v1.0.""" + uri = Path(get_data("testdata/formattest2_v1_0.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + uri = Path(get_data("testdata/formattest-job.json")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri( + "v1.0", uri, cwl_obj.loadingOptions + ) + assert jobfile["input"].format == cwl_obj.inputs[0].format + + +def test_v_1_0_load_inputfile_with_nested_array() -> None: + """Test that nested arrays are preserved when loading an input file with CWL v1.0.""" + uri = Path(get_data("testdata/nested-array-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.0", uri) + assert isinstance(jobfile["letters"], MutableSequence) + assert isinstance(jobfile["letters"][0], MutableSequence) + assert jobfile["letters"][0][0] == "a" + + +def test_v_1_0_load_inputfile_with_secondary_files() -> None: + """Test that secondary files are treated as objects when loading an input file with CWL v1.0.""" + uri = Path(get_data("testdata/dir4-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.0", uri) + assert isinstance(jobfile["inf"].secondaryFiles[0], cwl_utils.parser.cwl_v1_0.File) + assert isinstance( + jobfile["inf"].secondaryFiles[1], cwl_utils.parser.cwl_v1_0.Directory + ) + + def test_v1_0_stdout_to_file() -> None: """Test that stdout shortcut is converted to stdout parameter with CWL v1.0.""" clt = cwl_utils.parser.cwl_v1_0.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type_="stdout") ], ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) @@ -154,7 +183,7 @@ def test_v1_0_stdout_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_0.CommandOutputParameter( id="test", - type="stdout", + type_="stdout", outputBinding=cwl_utils.parser.cwl_v1_0.CommandOutputBinding( glob="output.txt" ), @@ -170,7 +199,7 @@ def test_v1_0_stdout_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_0.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type_="stdout") ], stdout="original.txt", ) @@ -184,7 +213,7 @@ def test_v1_0_stderr_to_file() -> None: clt = cwl_utils.parser.cwl_v1_0.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type_="stderr") ], ) cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(clt) @@ -199,7 +228,7 @@ def test_v1_0_stderr_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_0.CommandOutputParameter( id="test", - type="stderr", + type_="stderr", outputBinding=cwl_utils.parser.cwl_v1_0.CommandOutputBinding( glob="err.txt" ), @@ -215,7 +244,7 @@ def test_v1_0_stderr_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_0.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_0.CommandOutputParameter(id="test", type_="stderr") ], stderr="original.txt", ) @@ -229,7 +258,7 @@ def test_v1_0_type_compare_list() -> None: uri = Path(get_data("testdata/echo_v1_0.cwl")).resolve().as_uri() cwl_obj = load_document_by_uri(uri) assert cwl_utils.parser.cwl_v1_0_utils._compare_type( - cwl_obj.inputs[0].type, cwl_obj.inputs[0].type + cwl_obj.inputs[0].type_, cwl_obj.inputs[0].type_ ) @@ -291,8 +320,8 @@ def test_v1_0_type_output_source_record() -> None: MutableSequence[cwl_utils.parser.cwl_v1_0.RecordField], source_type.fields ) assert len(fields) == 2 - assert fields[0].type == "File" - assert fields[1].type == "File" + assert fields[0].type_ == "File" + assert fields[1].type_ == "File" def test_v1_0_type_for_output_source_with_single_scatter_step() -> None: @@ -413,12 +442,51 @@ def test_v1_1_file_content_larger_than_64_kB() -> None: assert content == text[0 : cwl_utils.parser.cwl_v1_1_utils.CONTENT_LIMIT] +def test_v_1_1_load_inputfile_with_format() -> None: + """Test that File object with the `format` field is correctly loaded with CWL v1.1.""" + uri = Path(get_data("testdata/formattest2_v1_1.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + uri = Path(get_data("testdata/formattest-job.json")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri( + "v1.1", uri, cwl_obj.loadingOptions + ) + assert jobfile["input"].format == cwl_obj.inputs[0].format + + +def test_v_1_1_load_inputfile_with_nested_array() -> None: + """Test that nested arrays are preserved when loading an input file with CWL v1.1.""" + uri = Path(get_data("testdata/nested-array-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.1", uri) + assert isinstance(jobfile["letters"], MutableSequence) + assert isinstance(jobfile["letters"][0], MutableSequence) + assert jobfile["letters"][0][0] == "a" + + +def test_v_1_1_load_inputfile_with_requirements() -> None: + """Test that an input file with the cwl:requirements directive is correctly loaded with CWL v1.1.""" + uri = Path(get_data("testdata/env-job3.yaml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.1", uri) + assert isinstance( + jobfile["cwl:requirements"][0], cwl_utils.parser.cwl_v1_1.EnvVarRequirement + ) + + +def test_v_1_1_load_inputfile_with_secondary_files() -> None: + """Test that secondary files are treated as objects when loading an input file with CWL v1.1.""" + uri = Path(get_data("testdata/dir4-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.1", uri) + assert isinstance(jobfile["inf"].secondaryFiles[0], cwl_utils.parser.cwl_v1_1.File) + assert isinstance( + jobfile["inf"].secondaryFiles[1], cwl_utils.parser.cwl_v1_1.Directory + ) + + def test_v1_1_stdout_to_file() -> None: """Test that stdout shortcut is converted to stdout parameter with CWL v1.1.""" clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type_="stdout") ], ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) @@ -433,7 +501,7 @@ def test_v1_1_stdout_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_1.CommandOutputParameter( id="test", - type="stdout", + type_="stdout", outputBinding=cwl_utils.parser.cwl_v1_1.CommandOutputBinding( glob="output.txt" ), @@ -449,7 +517,7 @@ def test_v1_1_stdout_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type_="stdout") ], stdout="original.txt", ) @@ -463,7 +531,7 @@ def test_v1_1_stderr_to_file() -> None: clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type_="stderr") ], ) cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(clt) @@ -478,7 +546,7 @@ def test_v1_1_stderr_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_1.CommandOutputParameter( id="test", - type="stderr", + type_="stderr", outputBinding=cwl_utils.parser.cwl_v1_1.CommandOutputBinding( glob="err.txt" ), @@ -494,7 +562,7 @@ def test_v1_1_stderr_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_1.CommandOutputParameter(id="test", type_="stderr") ], stderr="original.txt", ) @@ -507,7 +575,7 @@ def test_v1_1_stdin_to_file() -> None: """Test that stdin shortcut is converted to stdin parameter with CWL v1.1.""" clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[ - cwl_utils.parser.cwl_v1_1.CommandInputParameter(id="test", type="stdin") + cwl_utils.parser.cwl_v1_1.CommandInputParameter(id="test", type_="stdin") ], outputs=[], ) @@ -521,7 +589,7 @@ def test_v1_1_stdin_to_file_with_binding() -> None: inputs=[ cwl_utils.parser.cwl_v1_1.CommandInputParameter( id="test", - type="stdin", + type_="stdin", inputBinding=cwl_utils.parser.cwl_v1_1.CommandLineBinding( prefix="--test" ), @@ -537,7 +605,7 @@ def test_v1_1_stdin_to_file_fail_with_original() -> None: """Test that stdin shortcut fails when stdin parameter is defined with CWL v1.1.""" clt = cwl_utils.parser.cwl_v1_1.CommandLineTool( inputs=[ - cwl_utils.parser.cwl_v1_1.CommandInputParameter(id="test", type="stdin") + cwl_utils.parser.cwl_v1_1.CommandInputParameter(id="test", type_="stdin") ], outputs=[], stdin="original.txt", @@ -551,7 +619,7 @@ def test_v1_1_type_compare_list() -> None: uri = Path(get_data("testdata/echo_v1_1.cwl")).resolve().as_uri() cwl_obj = load_document_by_uri(uri) assert cwl_utils.parser.cwl_v1_1_utils._compare_type( - cwl_obj.inputs[0].type, cwl_obj.inputs[0].type + cwl_obj.inputs[0].type_, cwl_obj.inputs[0].type_ ) @@ -613,8 +681,8 @@ def test_v1_1_type_output_source_record() -> None: MutableSequence[cwl_utils.parser.cwl_v1_1.RecordField], source_type.fields ) assert len(fields) == 2 - assert fields[0].type == "File" - assert fields[1].type == "File" + assert fields[0].type_ == "File" + assert fields[1].type_ == "File" def test_v1_1_type_for_output_source_with_single_scatter_step() -> None: @@ -736,12 +804,51 @@ def test_v1_2_file_content_larger_than_64_kB() -> None: cwl_utils.parser.cwl_v1_2_utils.content_limit_respected_read(f) +def test_v_1_2_load_inputfile_with_format() -> None: + """Test that File object with the `format` field is correctly loaded with CWL v1.2.""" + uri = Path(get_data("testdata/formattest2.cwl")).resolve().as_uri() + cwl_obj = load_document_by_uri(uri) + uri = Path(get_data("testdata/formattest-job.json")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri( + "v1.2", uri, cwl_obj.loadingOptions + ) + assert jobfile["input"].format == cwl_obj.inputs[0].format + + +def test_v_1_2_load_inputfile_with_nested_array() -> None: + """Test that nested arrays are preserved when loading an input file with CWL v1.2.""" + uri = Path(get_data("testdata/nested-array-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.2", uri) + assert isinstance(jobfile["letters"], MutableSequence) + assert isinstance(jobfile["letters"][0], MutableSequence) + assert jobfile["letters"][0][0] == "a" + + +def test_v_1_2_load_inputfile_with_requirements() -> None: + """Test that an input file with the cwl:requirements directive is correctly loaded with CWL v1.2.""" + uri = Path(get_data("testdata/env-job3.yaml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.2", uri) + assert isinstance( + jobfile["cwl:requirements"][0], cwl_utils.parser.cwl_v1_2.EnvVarRequirement + ) + + +def test_v_1_2_load_inputfile_with_secondary_files() -> None: + """Test that secondary files are treated as objects when loading an input file with CWL v1.2.""" + uri = Path(get_data("testdata/dir4-job.yml")).resolve().as_uri() + jobfile = cwl_utils.parser.utils.load_inputfile_by_uri("v1.2", uri) + assert isinstance(jobfile["inf"].secondaryFiles[0], cwl_utils.parser.cwl_v1_2.File) + assert isinstance( + jobfile["inf"].secondaryFiles[1], cwl_utils.parser.cwl_v1_2.Directory + ) + + def test_v1_2_stdout_to_file() -> None: """Test that stdout shortcut is converted to stdout parameter with CWL v1.2.""" clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type_="stdout") ], ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) @@ -756,7 +863,7 @@ def test_v1_2_stdout_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_2.CommandOutputParameter( id="test", - type="stdout", + type_="stdout", outputBinding=cwl_utils.parser.cwl_v1_2.CommandOutputBinding( glob="output.txt" ), @@ -772,7 +879,7 @@ def test_v1_2_stdout_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type="stdout") + cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type_="stdout") ], stdout="original.txt", ) @@ -786,7 +893,7 @@ def test_v1_2_stderr_to_file() -> None: clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type_="stderr") ], ) cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(clt) @@ -801,7 +908,7 @@ def test_v1_2_stderr_to_file_with_binding() -> None: outputs=[ cwl_utils.parser.cwl_v1_2.CommandOutputParameter( id="test", - type="stderr", + type_="stderr", outputBinding=cwl_utils.parser.cwl_v1_2.CommandOutputBinding( glob="err.txt" ), @@ -817,7 +924,7 @@ def test_v1_2_stderr_to_file_preserve_original() -> None: clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[], outputs=[ - cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type="stderr") + cwl_utils.parser.cwl_v1_2.CommandOutputParameter(id="test", type_="stderr") ], stderr="original.txt", ) @@ -830,7 +937,7 @@ def test_v1_2_stdin_to_file() -> None: """Test that stdin shortcut is converted to stdin parameter with CWL v1.2.""" clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[ - cwl_utils.parser.cwl_v1_2.CommandInputParameter(id="test", type="stdin") + cwl_utils.parser.cwl_v1_2.CommandInputParameter(id="test", type_="stdin") ], outputs=[], ) @@ -844,7 +951,7 @@ def test_v1_2_stdin_to_file_with_binding() -> None: inputs=[ cwl_utils.parser.cwl_v1_2.CommandInputParameter( id="test", - type="stdin", + type_="stdin", inputBinding=cwl_utils.parser.cwl_v1_2.CommandLineBinding( prefix="--test" ), @@ -860,7 +967,7 @@ def test_v1_2_stdin_to_file_fail_with_original() -> None: """Test that stdin shortcut fails when stdin parameter is defined with CWL v1.2.""" clt = cwl_utils.parser.cwl_v1_2.CommandLineTool( inputs=[ - cwl_utils.parser.cwl_v1_2.CommandInputParameter(id="test", type="stdin") + cwl_utils.parser.cwl_v1_2.CommandInputParameter(id="test", type_="stdin") ], outputs=[], stdin="original.txt", @@ -874,7 +981,7 @@ def test_v1_2_type_compare_list() -> None: uri = Path(get_data("testdata/echo_v1_2.cwl")).resolve().as_uri() cwl_obj = load_document_by_uri(uri) assert cwl_utils.parser.cwl_v1_2_utils._compare_type( - cwl_obj.inputs[0].type, cwl_obj.inputs[0].type + cwl_obj.inputs[0].type_, cwl_obj.inputs[0].type_ ) @@ -936,8 +1043,8 @@ def test_v1_2_type_output_source_record() -> None: MutableSequence[cwl_utils.parser.cwl_v1_2.RecordField], source_type.fields ) assert len(fields) == 2 - assert fields[0].type == "File" - assert fields[1].type == "File" + assert fields[0].type_ == "File" + assert fields[1].type_ == "File" def test_v1_2_type_for_output_source_with_single_scatter_step() -> None: