diff --git a/ciscoconfparse/ccp_util.py b/ciscoconfparse/ccp_util.py index 90f4276d..78d452df 100644 --- a/ciscoconfparse/ccp_util.py +++ b/ciscoconfparse/ccp_util.py @@ -3991,6 +3991,7 @@ def parse_text_list(self, text, debug=False): # This method is on CiscoRange() @logger.catch(reraise=True) def __repr__(self): + """Return a formal string representation of this CiscoRange() object.""" return f"""""" # This method is on CiscoRange() @@ -4000,7 +4001,7 @@ def __len__(self): return len(self._list) def __iter__(self): - """Return an iterator for this CiscoRange()""" + """Return an iterator for this CiscoRange(). If CiscoRange().__iter__() is not implemented, many CiscoRnage() index errors are generated by other methods accessing an index that is off by one.""" return iter(self._list) # This method is on CiscoRange() @@ -4120,11 +4121,12 @@ def insert(self, idx, val, sort=True): # This method is on CiscoRange() @logger.catch(reraise=True) def __str__(self): + """Return a formal string representation of this CiscoRange()""" return "[" + str(", ".join([str(ii) for ii in self._list])) + "]" # This method is on CiscoRange() @logger.catch(reraise=True) - def remove(self, arg): + def remove(self, arg, debug=False): length_before = len(self._list) list_before = copy.deepcopy(self._list) # Try removing some common result types... @@ -4132,7 +4134,12 @@ def remove(self, arg): if result_type is None: new_list = [ii for ii in list_before if ii != arg] else: - new_list = [ii for ii in list_before if result_type(ii) != arg] + try: + new_list = [ii for ii in list_before if result_type(ii) != arg] + except TypeError as eee: + if debug is True: + error = "Found type mismatch: {arg}, {ii}" + logger.debug(error) if len(new_list) < length_before: self._list = new_list break