def _resolve_fuzzy(self, to_module): file_basename = StringTools.strip_suffix(os.path.basename( to_module.get_resource().name()), VSConstants.VCXProj_EXTENSION, ignore_case=True) candidates = list( filename for (filename, modulename) in self.__file_to_module_name_map.iteritems() if modulename == file_basename or os.path.basename(filename) == file_basename) candidates = sorted( candidates, key=lambda x: -len(self.__file_to_module_name_map[x])) if len(candidates): if len(candidates) > 1: self.__logger.warning( "Could not resolve project reference to %s exactly, but multiple fuzzy matches could be found in %s, using %s" % (to_module.get_resource().name(), ", ".join(candidates), candidates[0])) else: self.__logger.warning( "Could not resolve project reference to %s exactly, but a fuzzy match could be found in %s" % (to_module.get_resource().name(), candidates[0])) return self.__file_to_module_name_map[candidates[0]] return None
def test_strip_suffix_6(self): self.assertEquals('', StringTools.strip_suffix("", ""))
def test_strip_suffix_5(self): self.assertEquals('abcd', StringTools.strip_suffix("abcd", ""))
def test_strip_suffix_2(self): self.assertEquals('a', StringTools.strip_suffix("abcd", "BCD", ignore_case=True))
def test_strip_suffix_1(self): self.assertEquals('abcd', StringTools.strip_suffix("abcd", "BCD", ignore_case=False))