Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit 65da39f

Browse files
committed
Add explict requirement for in CiscoRange().as_list
1 parent 925a88a commit 65da39f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ciscoconfparse/ccp_util.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -3484,10 +3484,19 @@ def remove(self, arg):
34843484
@logger.catch(reraise=True)
34853485
def as_list(self):
34863486
"""Return a list of sorted components; an empty string is automatically rejected. This method is tricky to test due to the requirement for the `.sort_list` attribute on all elements; avoid using the ordered nature of `as_list` and use `as_set`."""
3487+
yy_list = copy.deepcopy(self._list)
3488+
for ii in self._list:
3489+
if isinstance(ii, str) and ii == "":
3490+
# Reject an empty string...
3491+
continue
3492+
if getattr(ii, "sort_list", None) is not None:
3493+
# Require the .sort_list attribute...
3494+
yy_list.append(ii)
3495+
3496+
self._list = yy_list
34873497
try:
3488-
[getattr(x, "sort_list") for x in self._list]
34893498
# Disable linter qa checks on this embedded list syntax...
3490-
return [str(ii) for ii in sorted(list(set(self._list)) if ii != "", key=lambda x: x.sort_list, reverse=False)] # noqa
3499+
return [self._list, key=lambda x: x.sort_list, reverse=False)] # noqa
34913500
except AttributeError as eee:
34923501
logger.error(eee)
34933502
raise ListItemMissingAttribute(eee)

0 commit comments

Comments
 (0)