Ejemplo n.º 1
0
 def test_exact_match(self):
     self.assertListEqual(['foO'],
                          functions.getStuffSoundingLike('foO', ['foO']))
     self.assertListEqual(
         ['foO'],
         functions.getStuffSoundingLike(
             'foO', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
Ejemplo n.º 2
0
 def test_substring_match(self):
     self.assertListEqual(
         ["averell"], functions.getStuffSoundingLike("ere", ["bar", "foO", "joe", "jack", "averell", "william"])
     )
     self.assertListEqual(
         ["joe", "jack"], functions.getStuffSoundingLike("j", ["bar", "foO", "joe", "jack", "averell", "william"])
     )
     self.assertListEqual(
         ["xxxfoOx1", "xxxfoOx2", "xxxfoOx3", "xxxfoOx4", "xxxfoOx5", "xxxfoOx6"],
         functions.getStuffSoundingLike(
             "foO", ["xxxfoOx1", "xxxfoOx2", "xxxfoOx3", "xxxfoOx4", "xxxfoOx5", "xxxfoOx6", "bar"]
         ),
     )
Ejemplo n.º 3
0
 def test_fallback(self):
     self.assertListEqual(
         sorted(['bar', 'william', 'joe', 'averell', 'foO', 'jack']),
         sorted(
             functions.getStuffSoundingLike(
                 'xxx',
                 ['bar', 'foO', 'joe', 'jack', 'averell', 'william'])))
Ejemplo n.º 4
0
    def getMapsFromListSoundingLike(self, mapname):
        """ return a valid mapname.
        If no exact match is found, then return close candidates as a list
        """
        wanted_map = mapname.lower()
        supportedMaps = self._mapsList
        if wanted_map in supportedMaps:
            return wanted_map

        cleaned_supportedMaps = {}
        for map_name in supportedMaps:
            cleaned_supportedMaps[re.sub("^ut4?_", '', map_name, count=1)] = map_name

        if wanted_map in cleaned_supportedMaps:
            return cleaned_supportedMaps[wanted_map]

        cleaned_wanted_map = re.sub("^ut4?_", '', wanted_map, count=1)

        matches = [cleaned_supportedMaps[match] for match in getStuffSoundingLike(cleaned_wanted_map, cleaned_supportedMaps.keys())]
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]
        else:
            # multiple matches, provide suggestions
            return matches
Ejemplo n.º 5
0
 def test_substring_match(self):
     self.assertListEqual(
         ['averell'],
         functions.getStuffSoundingLike(
             'ere', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
     self.assertListEqual(
         ['joe', 'jack'],
         functions.getStuffSoundingLike(
             'j', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
     self.assertListEqual([
         'xxxfoOx1', 'xxxfoOx2', 'xxxfoOx3', 'xxxfoOx4', 'xxxfoOx5',
         'xxxfoOx6'
     ],
                          functions.getStuffSoundingLike(
                              'foO', [
                                  'xxxfoOx1', 'xxxfoOx2', 'xxxfoOx3',
                                  'xxxfoOx4', 'xxxfoOx5', 'xxxfoOx6', 'bar'
                              ]))
Ejemplo n.º 6
0
    def getMapsSoundingLike(self, mapname):
        """ return a valid mapname.
        If no exact match is found, then return close candidates as a list
        """
        wanted_map = mapname.lower()
        supportedMaps = [x.lower() for x in self.console.getMaps()]
        if wanted_map in supportedMaps:
            return wanted_map

        matches = [match for match in getStuffSoundingLike(wanted_map, supportedMaps)]
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]
        else:
            # multiple matches, provide suggestions
            return matches
Ejemplo n.º 7
0
    def getMapsSoundingLike(self, mapname):
        """ return a valid mapname.
        If no exact match is found, then return close candidates as a list
        """
        supportedMaps = [m.lower() for m in self.getAvailableMaps()]
        wanted_map = mapname.lower()
        if wanted_map in supportedMaps:
            return wanted_map

        matches = getStuffSoundingLike(wanted_map, supportedMaps)
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]
        else:
            # multiple matches, provide suggestions
            return matches
Ejemplo n.º 8
0
    def getMapsSoundingLike(self, mapname):
        """
        Return a valid mapname.
        If no exact match is found, then return close candidates as a list
        """
        supported_maps = [m.lower() for m in self.getAvailableMaps()]
        wanted_map = mapname.lower()
        if wanted_map in supported_maps:
            return wanted_map

        matches = getStuffSoundingLike(wanted_map, supported_maps)
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]
        else:
            # multiple matches, provide suggestions
            return matches
Ejemplo n.º 9
0
    def getMapsSoundingLike(self, mapname):
        """
        Return a valid mapname.
        If no exact match is found, then return close candidates as a list.
        """
        wanted_map = mapname.lower()
        maps = self.console.getMaps()

        supported_maps = []
        if not self._skip_standard_maps:
            supported_maps = maps
        else:
            for m in maps:
                if self._skip_standard_maps:
                    if m.lower() in self.standard_maplist:
                        continue
                supported_maps.append(m)

        if wanted_map in supported_maps:
            return wanted_map

        cleaned_supported_maps = {}
        for map_name in supported_maps:
            cleaned_supported_maps[re.sub("^ut4?_", '', map_name, count=1)] = map_name

        if wanted_map in cleaned_supported_maps:
            return cleaned_supported_maps[wanted_map]

        cleaned_wanted_map = re.sub("^ut4?_", '', wanted_map, count=1)

        matches = [cleaned_supported_maps[match] for match in getStuffSoundingLike(cleaned_wanted_map,
                                                                                   cleaned_supported_maps.keys())]
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]

        # multiple matches, provide suggestions
        return matches
Ejemplo n.º 10
0
    def getMapsSoundingLike(self, mapname):
        """
        Return a valid mapname.
        If no exact match is found, then return close candidates as a list.
        """
        wanted_map = mapname.lower()
        maps = self.console.getMaps()

        supported_maps = []
        if not self._skip_standard_maps:
            supported_maps = maps
        else:
            for m in maps:
                if self._skip_standard_maps:
                    if m.lower() in self.standard_maplist:
                        continue
                supported_maps.append(m)

        if wanted_map in supported_maps:
            return wanted_map

        cleaned_supported_maps = {}
        for map_name in supported_maps:
            cleaned_supported_maps[re.sub("^ut4?_", '', map_name, count=1)] = map_name

        if wanted_map in cleaned_supported_maps:
            return cleaned_supported_maps[wanted_map]

        cleaned_wanted_map = re.sub("^ut4?_", '', wanted_map, count=1)

        matches = [cleaned_supported_maps[match] for match in getStuffSoundingLike(cleaned_wanted_map,
                                                                                   cleaned_supported_maps.keys())]
        if len(matches) == 1:
            # one match, get the map id
            return matches[0]

        # multiple matches, provide suggestions
        return matches
Ejemplo n.º 11
0
 def test_empty_expected_stuff(self):
     self.assertListEqual([], functions.getStuffSoundingLike('foO', []))
Ejemplo n.º 12
0
 def test_fallback(self):
     self.assertListEqual(
         ["bar", "foO", "joe", "jack", "averell", "william"],
         functions.getStuffSoundingLike("xxx", ["bar", "foO", "joe", "jack", "averell", "william"]),
     )
Ejemplo n.º 13
0
 def test_soundex_match(self):
     self.assertListEqual(
         ["jack"], functions.getStuffSoundingLike("jak", ["bar", "foO", "joe", "jack", "averell", "william"])
     )
Ejemplo n.º 14
0
 def test_empty_expected_stuff(self):
     self.assertListEqual([], functions.getStuffSoundingLike("foO", []))
 def test_substring_match(self):
     self.assertListEqual(['averell'], functions.getStuffSoundingLike('ere', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
     self.assertListEqual(['joe', 'jack'], functions.getStuffSoundingLike('j', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
     self.assertListEqual(['xxxfoOx1', 'xxxfoOx2', 'xxxfoOx3', 'xxxfoOx4', 'xxxfoOx5', 'xxxfoOx6'],
         functions.getStuffSoundingLike('foO', ['xxxfoOx1', 'xxxfoOx2', 'xxxfoOx3', 'xxxfoOx4', 'xxxfoOx5', 'xxxfoOx6', 'bar']))
 def test_soundex_match(self):
     self.assertListEqual(['jack'], functions.getStuffSoundingLike('jak', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))
 def test_fallback(self):
     self.assertListEqual(['bar', 'william', 'joe', 'averell', 'foO', 'jack'], functions.getStuffSoundingLike('xxx', ['bar', 'foO', 'joe', 'jack', 'averell', 'william']))