{"id":23727775,"url":"https://github.com/vladimirs-git/netports","last_synced_at":"2025-09-04T03:32:36.999Z","repository":{"id":62591373,"uuid":"487705314","full_name":"vladimirs-git/netports","owner":"vladimirs-git","description":"Python tools to parse and manage ranges of VLANs, TCP/UDP ports, IP protocol, Interfaces","archived":false,"fork":false,"pushed_at":"2025-06-17T08:27:44.000Z","size":441,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T13:06:01.275Z","etag":null,"topics":["ip","port","python","range","tcp","udp","vlan"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vladimirs-git.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-02T03:28:44.000Z","updated_at":"2025-06-17T08:27:48.000Z","dependencies_parsed_at":"2023-02-13T19:10:41.568Z","dependency_job_id":"1c42d2ab-13d9-4cf7-9f6f-122c9dfa0f70","html_url":"https://github.com/vladimirs-git/netports","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/vladimirs-git/netports","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Fnetports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Fnetports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Fnetports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Fnetports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladimirs-git","download_url":"https://codeload.github.com/vladimirs-git/netports/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Fnetports/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273547403,"owners_count":25125051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ip","port","python","range","tcp","udp","vlan"],"created_at":"2024-12-31T01:30:06.895Z","updated_at":"2025-09-04T03:32:36.975Z","avatar_url":"https://github.com/vladimirs-git.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n.. image:: https://img.shields.io/pypi/v/netports.svg\n   :target: https://pypi.python.org/pypi/netports\n.. image:: https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue.svg\n   :target: https://pypi.python.org/pypi/logger-color\n\n\nnetports\n========\n\nPython tools for managing ranges of VLANs, TCP/UDP ports, IP protocols, Interfaces\nRecommended for scripting in telecommunications networks.\n\n\nRequirements\n------------\n\nPython \u003e=3.8,\u003c3.12\n\n\nInstallation\n------------\n\nInstall the package from pypi.org release\n\n.. code:: bash\n\n    pip install netports\n\n\n.. contents:: **Contents**\n    :local:\n\n\nTCP/UDP ports\n-------------\n\ncheck_port()\n............\n**check_port(port, strict)**\nCheck TCP/UDP port in the range 1 to 65535.\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nport            *int*                       The TCP/UDP port that needs to be checked.\nstrict          *bool*                      True - raise NetportsValueError if the port is invalid, False - return False if the port is invalid. Default is `False`.\n=============== =========================== ============================================================================\n\nReturn\n    *bool* True - If the port is in the valid range of 1 to 65535, False - otherwise.\nRaises\n    *TypeError* If the port is not integer.\n    *NetportsValueError* If strict=True and the port is outside the valid range.\n\n\ncheck_ports()\n.............\n**check_ports(ports, strict)**\nCheck TCP/UDP ports in the range 1 to 65535.\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nports           *List[int]*                 The TCP/UDP ports that needs to be checked\nstrict          *bool*                      True - raise NetportsValueError if any in the ports is invalid, False - return False if the port is invalid. Default is `False`.\n=============== =========================== ============================================================================\n\nReturn\n    *bool* True - if all ports is in the valid range of 1 to 65535, False - otherwise.\nRaises\n    *TypeError* If any in the ports is not integer.\n    *NetportsValueError* If strict=True and any in the ports is outside the valid range.\n\n\nitcp()\n......\n**itcp(items, verbose, all)**\nInteger TCP/UDP Ports. Sorting TCP/UDP ports and removing duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of TCP/UDP ports, can be unsorted and with duplicates\nverbose         *bool*                      True - all ports in verbose mode: [1, 2, ..., 65535], False - all ports in brief mode: [-1], to save RAM (default)\nall             *bool*                      True - Returns all TCP/UDP ports: [1, 2, ..., 65535], or [-1] for verbose=False\n=============== =========================== ============================================================================\n\nReturn\n    *List[int]* of unique sorted TCP/UDP ports\nRaises\n    *NetportsValueError* if TCP/UDP ports are outside valid range 1...65535\n\n\n\nstcp()\n......\n**stcp(items, verbose, all)**\nString TCP/UDP ports. Sorting TCP/UDP ports and removing duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of TCP/UDP ports, can be unsorted and with duplicates\nverbose         *bool*                      True - all ports in verbose mode: [1, 2, ..., 65535], False - all ports in brief mode: [-1], to save RAM (default)\nall             *bool*                      True - Returns all TCP/UDP ports: \"1-65535\"\n=============== =========================== ============================================================================\n\nReturn\n    *str* of unique sorted TCP/UDP ports\nRaises\n    *NetportsValueError* if TCP/UDP ports are outside valid range 1...65535\n\n\n**Examples**\n\n`./examples/tcp_udp.py`_\n\n\n\nVLAN IDs\n--------\n\n\nivlan()\n.......\n**ivlan(items, verbose, all, splitter, range_splitter, platform)**\nSorting integer VLAN IDs and removing duplicates\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of VLANs, can be unsorted and with duplicates\nverbose         *bool*                      True - all VLAN IDs in verbose mode: [1, 2, ..., 65535], False - all VLAN IDs in brief mode: [-1], to save RAM (default)\nall             *bool*                      True - Returns all VLAN IDs: [1, 2, ..., 4094], or [-1] for verbose=False\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\nplatform        *str*                       Set ``splitter`` and ``range_splitter`` to platform specific values. Defined: \"cisco\" (Cisco IOS), \"hpe\" (Hewlett Packard Enterprise).\n=============== =========================== ============================================================================\n\nReturn\n    *List[int]* of unique sorted VLANs\nRaises\n    *NetportsValueError* if VLANs are outside valid range 1...4094\n\n\nsvlan()\n.......\n**svlan(items, verbose, all, splitter, range_splitter, platform)**\nSorting string VLANs and removing duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of VLANs, can be unsorted and with duplicates\nverbose         *bool*                      True - all VLAN IDs in verbose mode: [1, 2, ..., 65535], False - all VLAN IDs in brief mode: [-1], to save RAM (default)\nall             *bool*                      True - Returns all VLAN IDs: \"1-4094\"\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\nplatform        *str*                       Set ``splitter`` and ``range_splitter`` to platform specific values. Defined: \"cisco\" (Cisco IOS), \"hpe\" (Hewlett Packard Enterprise).\n=============== =========================== ============================================================================\n\nReturn\n    *str* of unique sorted VLANs\nRaises\n    *NetportsValueError* if VLANs are outside valid range 1...4094\n\n\n**Examples**\n\n`./examples/vlan.py`_\n\n\n\nIP protocols\n------------\n\n\nIP_NAMES, IP_NUMBERS\n....................\n\nDictionary with known IP protocol names and IDs listed in https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers\n\n\niip()\n.....\n**iip(items, verbose, all, strict)**\nSorting IP protocol numbers and removing duplicates\n\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of IP protocol numbers, can be unsorted and with duplicates, \"ip\" - Return all IP protocol numbers: [0, 1, ..., 255]\nverbose         *bool*                      True - all protocols in verbose mode: [0, 1, ..., 255], False - all protocols in brief mode: [-1], to save RAM (default)\nstrict          *bool*                      True - Raises NetportsValueError, if the protocol is unknown (default), False - Skips unknown protocols\nall             *bool*                      True - Return all IP protocol numbers: [0, 1, ..., 255]\n=============== =========================== ============================================================================\n\nReturn\n    *List[int]* of unique sorted IP protocol numbers\nRaises\n    *NetportsValueError* if IP protocol numbers are outside valid range 0...255\n\nsip()\n.....\n**sip(items, verbose, all)**\nSoring string IP protocol numbers and removing duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of IP protocol numbers, can be unsorted and with duplicates. \"ip\" - mean all numbers in range 0...255.\nverbose         *bool*                      True - all protocols in verbose mode: [0, 1, ..., 255], False - all protocols in brief mode: [-1], to save RAM (default)\nstrict          *bool*                      True - Raises NetportsValueError, if the protocol is unknown (default), False - Skips unknown protocols\nall             *bool*                      True - Return all IP protocol numbers: \"0-255\"\n=============== =========================== ============================================================================\n\nReturn\n    *str* of unique sorted IP protocol numbers\nRaises\n    *NetportsValueError* if IP protocol numbers are outside valid range 0...255\n\n\nip_pairs()\n..........\n**ip_pairs(items, strict)**\nSplits items to IP protocol Number, Name and undefined-invalid protocols\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of IP protocol names and numbers, can be unsorted and with duplicates\nverbose         *bool*                      True - all protocols in verbose mode: [0, 1, ..., 255], False - all protocols in brief mode: [-1], to save RAM (default)\n=============== =========================== ============================================================================\n\nReturn\n    *List[Tuple[int, str]]* Pairs of IP protocol number and name,\n     *List[str]* Undefined protocol names and invalid numbers\n\n\n**Examples**\n\n`./examples/ip.py`_\n\n\n\nObjects\n-------\n\nRange()\n.......\n**Range(items, splitter, range_splitter, strict)**\nAn object that represents ports range as *str* and as *List[int]*\nObject implements most of the `set \u003chttps://www.w3schools.com/python/python_ref_set.asp\u003e`_ and\n`list \u003chttps://www.w3schools.com/python/python_ref_list.asp\u003e`_ methods that handle the Range.numbers attribute.\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str*, *List[int]*          Range of numbers. Numbers can be unsorted and duplicated.\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\nstrict          *bool*                      True - Raise NetportsValueError, if in items is invalid item. False - Make Range without invalid items. By default True.\n=============== =========================== ============================================================================\n\nAttributes demonstration\n\n\nRange operators\n:::::::::::::::\n\n**Range** object implements:\n\n- Arithmetic operators: ``+``, ``-``\n- Reference to numbers in range by index\n\n=============================== =========================== ============================================================\nOperator                        Return                      Description\n=============================== =========================== ============================================================\nRange(\"1,4\") + Range(\"3,5\")     Range(\"1,3-5\")              Add two objects\nRange(\"1-5\") - Range(\"2\")       Range(\"1,3-5\")              Subtract two objects\nRange(\"1,3-5\")[1]               3                           Get number by index\nRange(\"1,3-5\")[1:3]             [3, 4]                      Get numbers by slice\n=============================== =========================== ============================================================\n\n\nRange methods\n:::::::::::::\n\n**Range** object implements most of `set \u003chttps://www.w3schools.com/python/python_ref_set.asp\u003e`_\nand `list \u003chttps://www.w3schools.com/python/python_ref_list.asp\u003e`_ methods.\n\n=================================== ====================================================================================\nMethod                              Description\n=================================== ====================================================================================\nadd(other)                          Adds other *Range* object to self\nappend(number)                      Appends number to self\nclear()                             Removes all numbers from self\ncopy()                              Returns a copy of self *Range* object\ndifference(other)                   Returns the *Range* object of the difference between self and other *Range*\ndifference_update(other)            Removes other *Range* from self\ndiscard(number)                     Removes the specified number from self *Range*\nextend(numbers)                     Adds *List[int]* numbers to self\nindex(number)                       Returns index of number, raises ValueError if the number is not present in range\nintersection(other)                 Returns *Range* which is the intersection of self and other *Range*\nintersection_update(other)          Removes numbers of other *Range* in self, that are not present in other\nisdisjoint(other)                   Returns whether self numbers and other *Range* numbers have intersection or not\nissubset(other)                     Returns whether other *Range* numbers contains self numbers or not\nissuperset(other)                   Returns whether self *Range* numbers contains other *Range* numbers set or not\npop()                               Removes and returns last number in *Range*, raises IndexError if list is empty or index is out of range\nremove(number)                      Removes the specified number from self *Range*, raises ValueError if the numbers is not present\nsymmetric_difference(other)         Returns *Range* object with the symmetric differences of self and other *Range*\nsymmetric_difference_update(other)  Inserts the symmetric differences from self *Range* and other *Range*\nupdate(other)                       Returns *Range* of the union of self *Range* and other *Range*\n=================================== ====================================================================================\n\n\n**Examples**\n\n- Attributes demonstration\n- Sorts numbers and removes duplicates\n- Range with custom splitters\n\n`./examples/range.py`_\n\n\n\nNumbers\n-------\n\nparse_range()\n.............\n**parse_range(line, splitter, range_splitter)**\nParses range from line. Removes white spaces considering splitters.\nSort numbers and removes duplicates.\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nline            *str*                       Range of numbers, can be unsorted and with duplicates\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\n=============== =========================== ============================================================================\n\nReturn\n    Range *object*\n\n\ninumbers()\n..........\n**inumbers(items, splitter, range_splitter)**\nSort integer numbers and removes duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of numbers, can be unsorted and with duplicates\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\n=============== =========================== ============================================================================\n\nReturn\n    *List[int]* of unique sorted numbers\n\n\nsnumbers()\n..........\n**snumbers(items, splitter, range_splitter)**\nSort string numbers and removes duplicates\n\n=============== =========================== ============================================================================\nParameter       Type                        Description\n=============== =========================== ============================================================================\nitems           *str, List[int], List[str]* Range of numbers, can be unsorted and with duplicates\nsplitter        *str*                       Separator character between items, by default \",\"\nrange_splitter  *str*                       Separator between min and max numbers in range, by default \"-\"\n=============== =========================== ============================================================================\n\nReturn\n    *str* of unique sorted numbers\n\n\n**Examples**\n\n- Sorts numbers and removes duplicates\n- Range with custom splitter and range_splitter\n- Converts unsorted range to sorted *List[int]* without duplicates\n- Converts unsorted range to *List[int]* with custom splitters\n- Converts unsorted range to sorted *str* without duplicates\n- Converts unsorted range to *str* with custom splitters\n\n`./examples/numbers.py`_\n\n\nInterfaces\n----------\n\ngenerate_intfs()\n................\n**generate_intfs(start, end, base)**\nGenerate list of Intf objects from start to end.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nstart       *str*        First interface name in the range.\nend         *str*        Last interface name in the range.\nbase        *str*        Prefix of the interface name that needs to be added to each interface.\n=========== ============ ===========================================================================\n\nReturn\n    *List[Intf]* List of generated Intf objects.\n\n\ngenerate_names()\n................\n**generate_names(start, end, base)**\nGenerate list of interface names from start to end.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nstart       *str*        First interface name in the range.\nend         *str*        Last interface name in the range.\nbase        *str*        Prefix of the interface name that needs to be added to each interface.\n=========== ============ ===========================================================================\n\nReturn\n    *List[str]* List of generated interface names.\n\n\nis_port_base()\n..............\n**is_port_base(port, required, ignore)**\nCheck if the port has one of the required base, skipping base that are in the ignore list.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nport        *str*        Port name that need to check.\nrequired    *List[str]*  Required base names (without ID), one of which should match with port base name.\nignore      *List[str]*  Base names to ignore.\n=========== ============ ===========================================================================\n\nReturn\n    *bool* True - if port base name matches with required, False - otherwise.\n\n\nnames_to_range()\n................\n**names_to_range(names, fmt)**\nJoin list of interface names to range.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nnames       *List[str]*  List of interface names.\nfmt         *str*        Format option: \"long\"  - Long names: [\"interface Ethernet1/1-3\"], \"short\" - Short names: [\"Eth1/1/1-3\"].\n=========== ============ ===========================================================================\n\nReturn\n    *str* Interface range.\n\n\nrange_to_intfs()\n................\n**range_to_intfs(line, base)**\nSplit interface range to list of Intf objects.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nline        *str*        Range of interfaces that need to be split.\nbase        *str*        Prefix of the interface name that needs to be added to each interface.\n=========== ============ ===========================================================================\n\nReturn\n    *List[Intf]* List of Intf objects.\n\n\nrange_to_names()\n................\n**range_to_names(line)**\nSplit interface range to list of interface names.\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nline        *str*        Range of interfaces that need to be split.\n=========== ============ ===========================================================================\n\nReturn\n    *List[str]* List of interface names.\n\n\nsort_names()\n............\n**sort_names(names, reverse)**\nSort interface names.\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\nnames           *List[str]*                 Interface names that need to be sorted.\nreverse         *bool*                      True - descending, False - ascending, default is False.\n=============== =========================== ============================================================================\n\nReturn\n    *List[str]* Sorted interface names.\n\n\nlong_to_short()\n...............\n**long_to_short(device_type, key_lower, value_lower)**\nReturns Interfaces map long-to-short, device_type specific\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nkey_lower       *bool*                      True - keys lower-case, False - keys upper-case\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case\n=============== =========================== ============================================================================\n\nReturn\n    *Dict[str, str]* Interfaces map\n\n\nlong_to_long()\n..............\n**long_to_long(device_type, key_lower, value_lower)**\nReturns Interfaces map long-to-long, device_type specific\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nkey_lower       *bool*                      True - keys lower-case, False - keys upper-case\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case\n=============== =========================== ============================================================================\n\nReturn\n    *Dict[str, str]* Interfaces map\n\n\nlongs()\n.......\n**longs(device_type, value_lower)**\nReturns long names of all interfaces\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case. Default is None, lower-case and upper-case.\n=============== =========================== ============================================================================\n\nReturn\n    *List[str]* Long names of all interfaces\n\n\nshort_to_long()\n...............\n**short_to_long(device_type, key_lower, value_lower)**\nReturns Interfaces map short-to-long, device_type specific\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nkey_lower       *bool*                      True - keys lower-case, False - keys upper-case\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case\n=============== =========================== ============================================================================\n\nReturn\n    *Dict[str, str]* Interfaces map\n\n\nshort_to_short()\n................\n**short_to_short(device_type, key_lower, value_lower)**\nReturns Interfaces map short-to-short, device_type specific\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nkey_lower       *bool*                      True - keys lower-case, False - keys upper-case\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case\n=============== =========================== ============================================================================\n\nReturn\n    *Dict[str, str]* Interfaces map\n\n\nshorts()\n........\n**shorts(device_type, value_lower)**\nReturns short names of all interfaces\n\n=============== =========================== ============================================================================\nParameter        Type                        Description\n=============== =========================== ============================================================================\ndevice_type     *str*                       Netmiko device type\nvalue_lower     *bool*                      True - values lower-case, False - values upper-case. Default is None, lower-case and upper-case.\n=============== =========================== ============================================================================\n\nReturn\n    *List[str]* Short names of all interfaces\n\n\nIntf()\n......\n**Intf(line, device_type, splitter)**\nAn object of interface name, that can contain up to 4 indexes.\nSorts the interfaces by indexes (not by alphabetic).\n\n=============== ======= ============================================================================\nParameter       Type    Description\n=============== ======= ============================================================================\nline            *str*   Interface name that can contain up to 4 indexes\ndevice_type     *str*   Netmiko device_type (default \"\")\nsplitter        *str*   Separator of characters between indexes (default \",./:\")\n=============== ======= ============================================================================\n\n\nIPv4()\n......\n**IPv4(addr, strict)**\nIPv4 address representation in CIDR notation with host data under mask bits.\n\n=============== ======= ============================================================================\nParameter       Type    Description\n=============== ======= ============================================================================\naddr            *str*   IPv4 address with host data under mask bits. A.B.C.D/LEN.\nstrict          *str*   If True, IP must be valid network address (not host address).\n=============== ======= ============================================================================\n\n\nMac()\n.....\n**Mac(addr)**\nMAC address representation in different formats\n\n=============== ======= ============================================================================\nParameter       Type    Description\n=============== ======= ============================================================================\naddr            *str*   MAC address\nhex             *str*   MAC address as 12-character hexadecimal string\ninteger         *int*   MAC address in integer format\n=============== ======= ============================================================================\n\n\nlast_idx()\n..........\n**last_idx()**\nIndex of last ID in interface line\n\n\nall_names()\n...........\n**all_names()**\nAll variants of names: long, short, upper-case, lover-case. Device type specific\n\n\nname_full()\n...........\n**name_full()**\nInterface long name with IDs and with interface keyword\n\n\nname_long()\n...........\n**name_long()**\nInterface long name with IDs and without interface keyword\n\n\nname_short()\n............\n**name_short(replace)**\nInterface short name with IDs, Device type specific\n\n=========== =========================== ============================================================\nParameter   Type                        Description\n=========== =========================== ============================================================\nreplace     *List[Tuple[str, str]]*     Replace the default short name with the first one\n                                        that matches in the list of the `replace` argument.\n=========== =========================== ============================================================\n\nReturn\n    *str* Interface short name.\n\n\npart_after()\n............\n**part_after(idx, splitter)**\nInterface part after interested ID\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nidx         *int*        Interface index\nsplitter    *bool*       True - Include splitter from edge, False - Skip splitter from edge\n=========== ============ ===========================================================================\n\nReturn\n    *str* Part of the interface name after specified interface index\n\n\npart_before()\n.............\n**part_before(idx, splitter)**\nInterface part before interested ID\n\n=========== ============ ===========================================================================\nParameter   Type         Description\n=========== ============ ===========================================================================\nidx         *int*        Interface index\nsplitter    *bool*       True - Include splitter from edge, False - Skip splitter from edge\n=========== ============ ===========================================================================\n\nReturn\n    *str* Part of the interface name before specified interface index\n\n\n**Examples**\n\n- Attributes demonstration\n- Interface with custom splitter between indexes. Splitter is ignored when comparing\n- Sorting by indexes\n- Grouping interfaces by 3rd index\n\n`./examples/intfs.py`_\n\n\nSwVersion()\n...........\n**SwVersion(text)**\nParse the given version string and return *SwVersion* object who can\ncompare (\u003e, \u003e=, \u003c, \u003c=) software versions of network devices: Cisco, FortiGate, HP, etc.\n\n\n.. code:: python\n\n    import re\n    from netports import SwVersion\n\n    text = \"Cisco IOS Software, C2960X Software (C2960X-UNIVERSALK9-M), Version 15.2(4)E10, ...\"\n    text = re.search(r\"Version (\\S+),\", text)[1]\n\n    version1 = SwVersion(text)  # 15.2(4)E10\n    version2 = SwVersion(\"15.2(4)E11\")\n\n    assert version1 \u003c version2\n    assert version1 \u003c= version2\n    assert not version1 \u003e version2\n    assert not version1 \u003e= version2\n    print(version1)  # 15.2(4)e10\n    print(version2)  # 15.2(4)e11\n\n\n.. _`./examples/tcp_udp.py` : ./examples/tcp_udp.py\n.. _`./examples/vlan.py` : ./examples/vlan.py\n.. _`./examples/ip.py` : ./examples/ip.py\n.. _`./examples/range.py` : ./examples/range.py\n.. _`./examples/numbers.py` : ./examples/numbers.py\n.. _`./examples/intfs.py` : ./examples/intfs.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirs-git%2Fnetports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladimirs-git%2Fnetports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirs-git%2Fnetports/lists"}