-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
There appears to be a logic issue with the following name conflict finding sub-routines. These methods exist in edifify_names.py
def _conflicts_good(self, obj, identifier, objects):
for element in objects:
if element == obj:
continue
if element.name == identifier or (
"EDIF.identifier" in element.data
and element["EDIF.identifier"] == identifier
):
return False
return True
def _conflicts_fix(self, obj, identifier, objects):
identifier_lower = identifier.lower()
if not self._conflicts_good(obj, identifier_lower, objects):
pattern = re.compile("_sdn_[0-9]+_$")
r = pattern.search(identifier_lower)
if r is None:
identifier_lower = identifier_lower + "_sdn_1_"
else:
# get the number out of the string
num = int(re.search(r"\d+", identifier_lower[r.start() :]).group())
identifier_lower = (
identifier_lower[: r.start() + 5] + str(num + 1) + "_"
)
identifier_lower = self._length_fix(identifier_lower)
identifier_lower = self._conflicts_fix(obj, identifier_lower, objects)
identifier = identifier_lower
return identifier
The medhod _conflict_fix() is making a lowercase version of the "identifier" parameter named "identifier_lower". It then tests if "identifier_lower" has any conflicts. If it does not have any conflicts, it returns the original un-modified "identifier". I believe it is possible for "identifier" to have a conflict, even if "identifier_lower" does not have a conflict. Python does perform case sensitive string comparison.
Metadata
Metadata
Assignees
Labels
No labels