Common Utils

class UnsortableList
sort(*args, **kwargs)

Stable sort IN PLACE.

class UnsortableOrderedDict
items() → a set-like object providing a view on D's items
check_path(path, create=False)
Parameters:
  • path
  • create
Returns:

convert_interface_name(interface: str, out: str = 'long')

This function converts interface names between long and short variants. For example Fa0/1 -> FastEthernet0/1 or the other way around.

Parameters:
  • interface
  • out
Return type:

str

Returns:

Interface string

get_logger(name, verbosity=4)
match_to_json(match, groups)

This function converts re match object to dict

Parameters:
  • match – re.match object
  • groups – list
Return type:

dict

Returns:

Dictionary with matched groups

split_interface_name(interface: str)

This function takes in interface string such as “GigabitEthernet0/10” and returns a list containing name and number, such as [“GigabitEthernet”, “0/10”]

Parameters:interface (str) – Interface to perform split on
Returns:List containing name and number of interface, such as ["GigabitEthernet", "0/10"]
Return type:list