Merge pull request #26 from mwalzer/fix#21appendix
addendum to fix for #21
chahuistle authored 6 years ago
GitHub committed 6 years ago
1003 | 1003 | if param.restrictions is not None: |
1004 | 1004 | # join all formats of the file, take mapping from supported_file if available for an entry |
1005 | 1005 | if type(param.restrictions) is _FileFormat: |
1006 | param_format = ','.join([get_supported_file_types(i, supported_file_formats) if | |
1007 | get_supported_file_types(i, supported_file_formats) | |
1006 | param_format = ','.join([get_supported_file_type(i, supported_file_formats) if | |
1007 | get_supported_file_type(i, supported_file_formats) | |
1008 | 1008 | else i for i in param.restrictions.formats]) |
1009 | 1009 | else: |
1010 | 1010 | raise InvalidModelException("Expected 'file type' restrictions for input file [%(name)s], " |
1047 | 1047 | if param.restrictions.n_max is not None: |
1048 | 1048 | param_node.attrib["max"] = str(param.restrictions.n_max) |
1049 | 1049 | elif type(param.restrictions) is _FileFormat: |
1050 | param_node.attrib["format"] = ",".join( | |
1051 | get_supported_file_types(param.restrictions.formats, supported_file_formats)) | |
1050 | param_node.attrib["format"] = ','.join([get_supported_file_type(i, supported_file_formats) if | |
1051 | get_supported_file_type(i, supported_file_formats) | |
1052 | else i for i in param.restrictions.formats]) | |
1052 | 1053 | else: |
1053 | 1054 | raise InvalidModelException("Unrecognized restriction type [%(type)s] for parameter [%(name)s]" |
1054 | 1055 | % {"type": type(param.restrictions), "name": param.name}) |
1314 | 1315 | return data_node |
1315 | 1316 | |
1316 | 1317 | |
1318 | # Get the supported file format for one given format | |
1319 | def get_supported_file_type(format_name, supported_file_formats): | |
1320 | if format_name in supported_file_formats.keys(): | |
1321 | return supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension | |
1322 | else: | |
1323 | return None | |
1324 | ||
1325 | ||
1317 | 1326 | def get_supported_file_types(formats, supported_file_formats): |
1318 | 1327 | return set([supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension |
1319 | 1328 | for format_name in formats if format_name in supported_file_formats.keys()]) |