def test_partial_key_match(): test_dict = { ('a', 'b', 'c'): (1, 2, 3), ('a', 'b', 'd'): (4, 5, 6), ('e', 'f', 'g'): (8, 7, 9) } assert list(util.partial_key_match( ('a', None, 'c'), test_dict))[0] == test_dict[('a', 'b', 'c')]
def _get_source_id(self, key): """ Returns source_id based on the key. """ source_id_list = list(partial_key_match(key, self.data_sources)) if len(source_id_list) != 1: raise KeyError(f"The values used: {key} do not correspond to one source_id " f"but {len(source_id_list)} source_id(s)." " Please check the list using HelioviewerClient.data_sources.") return source_id_list[0]
def _get_source_id(self, key): """ Returns source_id based on the key. """ source_id_list = list(partial_key_match(key, self.data_sources)) if len(source_id_list) > 1: # or maybe != 1 raise KeyError(f"The values used: {key} do not correspond to one source_id " f"but {len(source_id_list)} source_id(s)." " Please check the list using HelioviewerClient.data_sources.") return source_id_list[0]