def sort_for_yaml_dump(dictionary, category): """Sorts the objects of the specified category in the dictionary and returns them. If the category sorting is unknown, return the dictionary instead. Supported categories are: *materials*, *motors*, *sensors*, *simulation*. Args: structure(dict): dictionary to sort category(str): category of the dictionary to sort dictionary: Returns: : list -- the elements of the specified category of the original dictionary in sorted order """ if category in ['materials', 'motors']: return {category: sort_dict_list(dictionary[category], 'name')} elif category == 'sensors': dictionary[category] = models.replace_object_links( dictionary[category]) return {category: sort_dict_list(dictionary[category], 'name')} elif category == 'simulation': return_dict = {} for viscol in ['collision', 'visual']: return_dict[viscol] = sort_dict_list(dictionary[viscol], 'name') return return_dict return dictionary
def sort_for_yaml_dump(dictionary, category): """Sorts the objects of the specified category in the dictionary and returns them. If the category sorting is unknown, return the dictionary instead. Supported categories are: *materials*, *motors*, *sensors*, *simulation*. Args: structure(dict): dictionary to sort category(str): category of the dictionary to sort dictionary: Returns: : list -- the elements of the specified category of the original dictionary in sorted order """ if category in ['materials', 'motors']: return {category: sort_dict_list(dictionary[category], 'name')} elif category == 'sensors': dictionary[category] = models.replace_object_links(dictionary[category]) return {category: sort_dict_list(dictionary[category], 'name')} elif category == 'simulation': return_dict = {} for viscol in ['collision', 'visual']: return_dict[viscol] = sort_dict_list(dictionary[viscol], 'name') return return_dict return dictionary