From 445f6ae3b1bf63d04a6a03b3476db81a69ae5d39 Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Thu, 10 Aug 2023 22:01:32 -0400 Subject: [PATCH] Update spelling --- docs/user/lib_use_cases.md | 5 ++++- docs/user/lib_use_cases_protocol_mappers.md | 4 ++-- netutils/interface.py | 10 +++++----- netutils/password.py | 6 +++--- netutils/regex.py | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/user/lib_use_cases.md b/docs/user/lib_use_cases.md index 2e01aa04..9a5d230c 100644 --- a/docs/user/lib_use_cases.md +++ b/docs/user/lib_use_cases.md @@ -6,12 +6,13 @@ As the Python library is intended to be a low-level implementation, the primary Functions are grouped with like functions, such as IP or MAC address based functions. Included to date are groupings of: +- ASN - Provides the ability to convert BGP ASN from integer to dot notation and back. - Bandwidth - Provides the ability to convert between various bandwidth values. - Banner - Provides the ability to normalize the various banner delimiters. -- BGP ASN - Provides the ability to convert BGP ASN from integer to dot notation. - Configuration - Cleaning - Provides the ability to remove or replace lines based on regex matches. - Compliance - Provides the ability to compare two configurations to sanely understand the differences. + - Conversion - Provides the ability to convert between different syntax's within the same OS. - Parsing - Provides the ability to parse configuration for the minor differences that are there. - DNS - Provides the ability to work with DNS, such as validating that a FQDN is resolvable. - Interface - Provides the ability to work with interface names, expanding, abbreviating, and splitting the names. @@ -19,9 +20,11 @@ Functions are grouped with like functions, such as IP or MAC address based funct - Library Helpers - Provides helpers to pull useful information, e.g. NAPALM getters. - Library Mapper - Provides mappings in expected vendor names between Netmiko, NAPALM, pyntc, ntc-templates, pyats, and scrapli. - MAC Address - Provides the ability to work with MAC addresses such as validating or converting to integer. +- OS Version - Provides the ability to work with OS version, such as defining an upgrade path. - Password - Provides the ability to compare and encrypt common password schemas such as type5 and type7 Cisco passwords. - Ping - Provides the ability to ping, currently only tcp ping. - Protocol Mapper - Provides a mapping for protocol names to numbers and vice versa. +- Regex - Provide convenience methods for regex to be used in Jinja2. - Route - Provides the ability to provide a list of routes and an IP Address and return the longest prefix matched route. - Time -Provides the ability to convert between integer time and string times. - VLANs - Provide the ability to convert configuration into lists or lists into configuration. diff --git a/docs/user/lib_use_cases_protocol_mappers.md b/docs/user/lib_use_cases_protocol_mappers.md index 747b4c4c..7c071de4 100644 --- a/docs/user/lib_use_cases_protocol_mappers.md +++ b/docs/user/lib_use_cases_protocol_mappers.md @@ -79,11 +79,11 @@ Take the below example. |compressnet| 3| tcp| Compression Process | |compressnet| 3| udp| Compression Process | -As you can see, the service name and port comboniation is not unique. As such, on the second one, a `-secondary` is appended to the name to accomdate. The resulting structure looks something like: +As you can see, the service name and port combination is not unique. As such, on the second one, a `-secondary` is appended to the name to accommodate. The resulting structure looks something like: ```python "compressnet": {"port_number": 2, "protocols": ["tcp", "udp"]}, "compressnet-secondary": {"port_number": 3, "protocols": ["tcp", "udp"]}, ``` -This behaviour is to be expected. \ No newline at end of file +This behavior is to be expected. \ No newline at end of file diff --git a/netutils/interface.py b/netutils/interface.py index 0c50625c..154aad8d 100644 --- a/netutils/interface.py +++ b/netutils/interface.py @@ -147,8 +147,8 @@ def canonical_interface_name_list( """Function to return a list of interface's canonical name (fully expanded name). Use of explicit matches used to indicate a clear understanding on any potential - match. Regex and other looser matching methods were not implmented to avoid false - positive matches. As an example, it would make sense to do "[P|p][O|o]" which would + match. Regex and other looser matching methods were not implemented to avoid false + positive matches. As an example, it would make sense to do `[P|p][O|o]` which would incorrectly match PO = POS and Po = Port-channel, leading to a false positive, not easily troubleshot, found, or known. @@ -420,7 +420,7 @@ def _iter_tree(node: t.Dict[CharacterClass, t.Any], parents: t.List[CharacterCla """Walk a tree of interface name parts. Weights are assigned based on domain logic to produce a - 'cannonical' ordering of names. + 'canonical' ordering of names. """ for _, items in itertools.groupby(sorted(node.keys()), lambda t: t.weight): for item in sorted(items): @@ -446,8 +446,8 @@ def sort_interface_list(interfaces: t.List[str]) -> t.List[str]: Examples: >>> sort_interface_list(["Gi1/0/1", "Gi1/0/3", "Gi1/0/3.100", "Gi1/0/2", "Gi1/0/2.50", "Gi2/0/2", "Po40", "Po160", "Lo10"]) ['Gi1/0/1', 'Gi1/0/2', 'Gi1/0/2.50', 'Gi1/0/3', 'Gi1/0/3.100', 'Gi2/0/2', 'Lo10', 'Po40', 'Po160'] - >>> sort_interface_list(['GigabitEthernet1/0/1', 'GigabitEthernet1/0/3', 'GigabitEthernet1/0/2', "GigabitEthernett3/0/5", 'GigabitEthernet3/0/7', 'GigabitEthernet2/0/8.5', 'Port-channel40', 'Vlan20', 'Loopback10']) - ['GigabitEthernet1/0/1', 'GigabitEthernet1/0/2', 'GigabitEthernet1/0/3', 'GigabitEthernet2/0/8.5', 'GigabitEthernet3/0/7', 'GigabitEthernett3/0/5', 'Loopback10', 'Port-channel40', 'Vlan20'] + >>> sort_interface_list(['GigabitEthernet1/0/1', 'GigabitEthernet1/0/3', 'GigabitEthernet1/0/2', "GigabitEthernet3/0/5", 'GigabitEthernet3/0/7', 'GigabitEthernet2/0/8.5', 'Port-channel40', 'Vlan20', 'Loopback10']) + ['GigabitEthernet1/0/1', 'GigabitEthernet1/0/2', 'GigabitEthernet1/0/3', 'GigabitEthernet2/0/8.5', 'GigabitEthernet3/0/5', 'GigabitEthernet3/0/7', 'Loopback10', 'Port-channel40', 'Vlan20'] """ root: t.Dict[CharacterClass, t.Any] = {} for ifname in interfaces: diff --git a/netutils/password.py b/netutils/password.py index 02f1bd86..5a9026a7 100644 --- a/netutils/password.py +++ b/netutils/password.py @@ -250,12 +250,12 @@ def encrypt_cisco_type5(unencrypted_password: str, salt: t.Optional[str] = None, if not salt: salt = "".join(secrets.choice(ALPHABET) for _ in range(salt_len)) elif not set(salt) <= set(ALPHABET): - raise ValueError(f"type5_pw salt used inproper characters, must be one of {ALPHABET}") + raise ValueError(f"type5_pw salt used improper characters, must be one of {ALPHABET}") return crypt.crypt(unencrypted_password, f"$1${salt}$") def encrypt_cisco_type7(unencrypted_password: str, salt: t.Optional[int] = None) -> str: - """Given an unencrypted password of Cisco Type 7 password, encypt it. + """Given an unencrypted password of Cisco Type 7 password, encrypt it. Args: unencrypted_password: A password that has not been encrypted, and will be compared against. @@ -397,7 +397,7 @@ def decrypt_juniper_type9(encrypted_password: str) -> str: nibble = stripped_password_characters[0 : len(decode)] # noqa: E203 stripped_password_characters = stripped_password_characters[len(decode) :] # noqa: E203 - # Decode value for nibble and convert to character, append to decryped password + # Decode value for nibble and convert to character, append to decrypted password value = 0 for index, char in enumerate(nibble): gap = ( diff --git a/netutils/regex.py b/netutils/regex.py index 67472ddb..cf851e76 100644 --- a/netutils/regex.py +++ b/netutils/regex.py @@ -109,7 +109,7 @@ def regex_search(pattern: str, string: str) -> t.Union[t.List[str], str, None]: def regex_split(pattern: str, string: str, maxsplit: int = 0) -> t.List[str]: - """Given a regex pattern and string, return the split the object based on the patern a single element or single element of original value if there is no match. + """Given a regex pattern and string, return the split the object based on the pattern a single element or single element of original value if there is no match. The main purpose of this function is provide a Jinja2 filter as this is simply a wrapper around `re.split`.