diff --git a/requirements.txt b/requirements.txt index 82d5bad7..3c5a1d9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ schematics~=2.1.1 pyyaml~=6.0.2 -fuzzywuzzy~=0.18.0 +thefuzz~=0.22.1 pluralizer~=1.2.0 lxml>=5.0.0 flask~=3.0.3 @@ -12,6 +12,5 @@ MarkupSafe>=2.1.5 jsonschema~=4.23.0 click~=8.1.2 setuptools>=78.1.1 -python-Levenshtein azure-mgmt-core azdev diff --git a/src/aaz_dev/swagger/model/specs/_resource.py b/src/aaz_dev/swagger/model/specs/_resource.py index 98a3fc5c..efbce1e4 100644 --- a/src/aaz_dev/swagger/model/specs/_resource.py +++ b/src/aaz_dev/swagger/model/specs/_resource.py @@ -4,7 +4,7 @@ import os import re -from fuzzywuzzy import fuzz +from thefuzz import fuzz from command.model.configuration import CMDResource from ._utils import map_path_2_repo @@ -62,9 +62,11 @@ def get_operation_group_name(self): if len(operation_groups) == 1: return operation_groups.pop() + # use the name which is closest to resource_id. resource_id is lower case, so compare + # case-insensitively, and break ties by length then name so the choice is deterministic. op_group_name = sorted( operation_groups, - key=lambda nm: fuzz.partial_ratio(self.id, nm), # use the name which is closest to resource_id + key=lambda nm: (fuzz.partial_ratio(self.id, nm.lower()), len(nm), nm), reverse=True )[0] setattr(self, "_op_group_name", op_group_name)