[fix] suggestion to fix #21
Before, if no _supported file formats_ were given, the format given in the CTD was ignored, leaving the format attribute as ```format=""```. Now, mappings will be considered, but if not available, the format from the CTD will be considered.
walzer
6 years ago
1007 | 1007 | # assume it's just text unless restrictions are provided |
1008 | 1008 | param_format = "text" |
1009 | 1009 | if param.restrictions is not None: |
1010 | # join all supported_formats for the file... this MUST be a _FileFormat | |
1011 | if type(param.restrictions) is _FileFormat: | |
1012 | param_format = ','.join(get_supported_file_types(param.restrictions.formats, supported_file_formats)) | |
1010 | # join all formats of the file, take mapping from supported_file if available for an entry | |
1011 | if type(param.restrictions) is _FileFormat: | |
1012 | param_format = ','.join([get_supported_file_types(i, supported_file_formats) if | |
1013 | get_supported_file_types(i, supported_file_formats) | |
1014 | else i for i in param.restrictions.formats]) | |
1013 | 1015 | else: |
1014 | 1016 | raise InvalidModelException("Expected 'file type' restrictions for input file [%(name)s], " |
1015 | 1017 | "but instead got [%(type)s]" |
1016 | 1018 | % {"name": param.name, "type": type(param.restrictions)}) |
1019 | ||
1017 | 1020 | param_node.attrib["type"] = "data" |
1018 | param_node.attrib["format"] = param_format | |
1021 | param_node.attrib["format"] = param_format | |
1019 | 1022 | # in the case of multiple input set multiple flag |
1020 | 1023 | if param.is_list: |
1021 | 1024 | param_node.attrib["multiple"] = "true" |