binip


Namebinip JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryA package for facilitating various IP and subnet operations.
upload_time2024-04-16 17:32:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseCopyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ip network subnet
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Binip

### Description:

Library for IP networking and subnetting.

### Installation:

Download .whl file and run:

    pip install binip

### Usage:

Import the desired classes and or functions:

    from binip.classes import [class]
    from binip.functions import [function]

### Documentation:

**Classes:**

IP:

Input: IPv4 or IPv6 address.

    ipv4 = IP('192.168.1.24')
    ipv6 = IP('ac43:34f:45bc:2c:0:0:0:12')

Attributes:

- address: str, IP address.

        ipv4.address
        '192.168.1.24'
  
- iptype: str, 'v4' or 'v6'.

        ipv4.iptype
        'v4'
  
- expanded(for IPv6 only):str, expanded IPv6 address.

        ipv6.expanded
        'ac43:034f:45bc:002c:0000:0000:0000:0012'

- contracted(for IPv6 only):str, contracted IPv6 address.

        ipv6.contracted
        'ac43:34f:45bc:2c::12'

Methods:

- validate_address:

  Validates a given IP address, works for both IPv4 and IPv6.
  
- ip_type:

  Returns either 'v4' or 'v6'.
  
- ipv6_expand:

  Given a shortened IPv6 address will return the unshortened version.
  
- ipv6_contract:

  Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.
  
- binip:

  Given an IP will return the IP in binary format.  Works for both IPv4 and IPv6.
  
- in_subnet

  Given a subnet will return True if the IP is in that subnet, will return False if otherwise.  Works for both IPv4 and IPv6.

Subnet:

Input: IPv4 or IPv6 subnet address, CIDR notation.

    subnetv4 = Subnet('192.168.1.12/24')
    subnetv6 = Subnet('ac43:34f:45bc:2c:0:0:0:12/64')

Attributes:

- subnet: str, subnet address.

        subnetv4.subnet
        '192.168.1.12/24'

- network: str, network address for subnet.

        subnetv4.network
        '192.168.1.0'

- networkcidr: str, network address for subnet in CIDR notation.

        subnetv4.networkcidr
        '192.168.1.0/24'

- broadcast: str, broadcast address for subnet.

        subnetv4.broadcast
        '192.168.1.255'

- broadcastcidr: str, broadcast address for subnet in CIDR notation.

        subnetv4.broadcastcidr
        '192.168.1.255/24'

- mask: int, subnet mask.

        subnetv4.mask
        24

- iptype: str, 'v4' or 'v6'.

        subnetv4.iptype
        'v4'

- info: dict, info on subnet.

        subnetv4.info
        {'Network': '192.168.1.0', 'Broadcast': '192.168.1.255', 'Clients:': 254, 'Range:': ('192.168.1.1','192.168.1.254')}


Methods:

- validate_address:
  
  Validates a given IP address, works for both IPv4 and IPv6.
  
- ip_type:
  
  Returns either 'v4' or 'v6'.
  
- ipv6_expand:

  Given a shortened IPv6 address will return the unshortened version.
  
- ipv6_contract:

  Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.
  
- binip:

  Given an IP will return the IP in binary format.  Works for both IPv4 and IPv6.
  
- in_subnet:

  Given an IP will return True if the IP is in the subnet, will return False if otherwise.  Works for both IPv4 and IPv6.
  
- subnet_info:
  
  Returns the network address, broadcast address and number of client IPs available for the subnet.
  
- toRegexv4:

  Returns a RegEx pattern to match the given IPv4 subnet.
  
- toRegexv6:

  Returns a RegEx pattern to match the given IPv6 subnet.
  
- ipgen:

  Generator function to iterate over IPs in the Subnet given a starting index, ending index and step.
    
**Functions:**

- ip_type: Returns either 'v4' or 'v6'.  Works for both IP and subnet addresses.

        ip_type('192.168.1.24')
        v4

- ipv6_expand: Given a shortened IPv6 address will return the unshortened version.

        ipv6_expand('ac43:34f:45bc:2c::12')
        'ac43:034f:45bc:002c:0000:0000:0000:0012'
    
- ipv6_contract: Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.

        ipv6_contract('ac43:034f:45bc:002c:0000:0000:0000:0012')
        'ac43:34f:45bc:2c::12'
    
- ip2bin: Given an IP address, in either decimal or hexadecimal format, returns the same IP address in binary format.

        ip2bin('192.168.1.24')
        '11000000101010000000000100011000'
    
- bin2ip: Given an IP address in binary format returns the same IP address in either decimal or hexadecimal format.

        bin2ip('11000000101010000000000100011000')
        '192.168.1.24'
    
- in_subnet: Given a subnet and an IP will return True if the IP is in that subnet, will return False if otherwise.  Works for both IPv4 and IPv6.

        in_subnet('192.168.1.24', '192.168.1.0/24')
        True
        in_subnet('192.168.1.24', '192.168.2.0/24')
        False

- overlap: Given two subnets two subnets will return True if they overlap or are identical.  Will return False if the subnets don't overlap.

        overlap('172.16.0.0/12', '172.16.0.0/16')
        True
        overlap('172.16.0.0/12', '172.10.0.0/16')
        False
        
- hex_range: Given the first and last hexadecimal values of a range returns a list of ReGex patterns to match each value of that range. Used in the toRegexv6 function.

        hex_range('0000', 'aaaa')
        hex_range('0000', 'aaaa')
        ['[0-9a-f]{0,1}', '[0-9a-f]{0,1}[0-9a-f]{0,1}', '[0-9a-f]{1}[0-9a-f]{0,2}', '[1-9]{0,1}[0-9a-f]{0,3}', 'aaa[0-9a-a]{0,1}', 'aa[0-9a-9]{1}[0-9a-f]{0,1}', 'a[0-9a-9]{1}[0-9a-f]{0,2}']
    
- toRegexv4: Returns a RegEx pattern to match the given IPv4 subnet. Used in the toRegex function.

        toRegexv4('192.168.1.0/14')
        '192.[1][6][8-9].[0-9]{1,3}.[0-9]{1,3}|192.[1][7][0-1].[0-9]{1,3}.[0-9]{1,3}'
    
- toRegexv6: Returns a RegEx pattern to match the given IPv6 subnet. Used in the toRegex function.

        toRegexv6('ac43:34f:45bc:2c::12/56')
        'ac43:34f:45bc:[0-9a-f]{0,1}:.*|ac43:34f:45bc:[0-9a-f]{0,1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:[1-9a-e]{1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:f[0-9a-f]{0,1}:.*'

- toRegex: Returns a RegEx pattern to match the given subnet.  Works for both IPv4 and IPv6.

        toRegexv4('192.168.1.0/14')
        '192.[1][6][8-9].[0-9]{1,3}.[0-9]{1,3}|192.[1][7][0-1].[0-9]{1,3}.[0-9]{1,3}'
        toRegexv6('ac43:34f:45bc:2c::12/56')
        'ac43:34f:45bc:[0-9a-f]{0,1}:.*|ac43:34f:45bc:[0-9a-f]{0,1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:[1-9a-e]{1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:f[0-9a-f]{0,1}:.*'

### License:

Basic MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "binip",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "IP, network, subnet",
    "author": null,
    "author_email": "Lo\u00efc James McKeever <loicjamesmckeever@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/00/3e/43df1456d7afc285fe3110d92f275a48d2a558f80c494547b5801d4caa45/binip-1.0.2.tar.gz",
    "platform": null,
    "description": "# Binip\n\n### Description:\n\nLibrary for IP networking and subnetting.\n\n### Installation:\n\nDownload .whl file and run:\n\n    pip install binip\n\n### Usage:\n\nImport the desired classes and or functions:\n\n    from binip.classes import [class]\n    from binip.functions import [function]\n\n### Documentation:\n\n**Classes:**\n\nIP:\n\nInput: IPv4 or IPv6 address.\n\n    ipv4 = IP('192.168.1.24')\n    ipv6 = IP('ac43:34f:45bc:2c:0:0:0:12')\n\nAttributes:\n\n- address: str, IP address.\n\n        ipv4.address\n        '192.168.1.24'\n  \n- iptype: str, 'v4' or 'v6'.\n\n        ipv4.iptype\n        'v4'\n  \n- expanded(for IPv6 only):str, expanded IPv6 address.\n\n        ipv6.expanded\n        'ac43:034f:45bc:002c:0000:0000:0000:0012'\n\n- contracted(for IPv6 only):str, contracted IPv6 address.\n\n        ipv6.contracted\n        'ac43:34f:45bc:2c::12'\n\nMethods:\n\n- validate_address:\n\n  Validates a given IP address, works for both IPv4 and IPv6.\n  \n- ip_type:\n\n  Returns either 'v4' or 'v6'.\n  \n- ipv6_expand:\n\n  Given a shortened IPv6 address will return the unshortened version.\n  \n- ipv6_contract:\n\n  Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.\n  \n- binip:\n\n  Given an IP will return the IP in binary format.  Works for both IPv4 and IPv6.\n  \n- in_subnet\n\n  Given a subnet will return True if the IP is in that subnet, will return False if otherwise.  Works for both IPv4 and IPv6.\n\nSubnet:\n\nInput: IPv4 or IPv6 subnet address, CIDR notation.\n\n    subnetv4 = Subnet('192.168.1.12/24')\n    subnetv6 = Subnet('ac43:34f:45bc:2c:0:0:0:12/64')\n\nAttributes:\n\n- subnet: str, subnet address.\n\n        subnetv4.subnet\n        '192.168.1.12/24'\n\n- network: str, network address for subnet.\n\n        subnetv4.network\n        '192.168.1.0'\n\n- networkcidr: str, network address for subnet in CIDR notation.\n\n        subnetv4.networkcidr\n        '192.168.1.0/24'\n\n- broadcast: str, broadcast address for subnet.\n\n        subnetv4.broadcast\n        '192.168.1.255'\n\n- broadcastcidr: str, broadcast address for subnet in CIDR notation.\n\n        subnetv4.broadcastcidr\n        '192.168.1.255/24'\n\n- mask: int, subnet mask.\n\n        subnetv4.mask\n        24\n\n- iptype: str, 'v4' or 'v6'.\n\n        subnetv4.iptype\n        'v4'\n\n- info: dict, info on subnet.\n\n        subnetv4.info\n        {'Network': '192.168.1.0', 'Broadcast': '192.168.1.255', 'Clients:': 254, 'Range:': ('192.168.1.1','192.168.1.254')}\n\n\nMethods:\n\n- validate_address:\n  \n  Validates a given IP address, works for both IPv4 and IPv6.\n  \n- ip_type:\n  \n  Returns either 'v4' or 'v6'.\n  \n- ipv6_expand:\n\n  Given a shortened IPv6 address will return the unshortened version.\n  \n- ipv6_contract:\n\n  Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.\n  \n- binip:\n\n  Given an IP will return the IP in binary format.  Works for both IPv4 and IPv6.\n  \n- in_subnet:\n\n  Given an IP will return True if the IP is in the subnet, will return False if otherwise.  Works for both IPv4 and IPv6.\n  \n- subnet_info:\n  \n  Returns the network address, broadcast address and number of client IPs available for the subnet.\n  \n- toRegexv4:\n\n  Returns a RegEx pattern to match the given IPv4 subnet.\n  \n- toRegexv6:\n\n  Returns a RegEx pattern to match the given IPv6 subnet.\n  \n- ipgen:\n\n  Generator function to iterate over IPs in the Subnet given a starting index, ending index and step.\n    \n**Functions:**\n\n- ip_type: Returns either 'v4' or 'v6'.  Works for both IP and subnet addresses.\n\n        ip_type('192.168.1.24')\n        v4\n\n- ipv6_expand: Given a shortened IPv6 address will return the unshortened version.\n\n        ipv6_expand('ac43:34f:45bc:2c::12')\n        'ac43:034f:45bc:002c:0000:0000:0000:0012'\n    \n- ipv6_contract: Returns shortened IPv6 address.  Removes leading zeros and contracts largest set of repeating zero hexadecatets.\n\n        ipv6_contract('ac43:034f:45bc:002c:0000:0000:0000:0012')\n        'ac43:34f:45bc:2c::12'\n    \n- ip2bin: Given an IP address, in either decimal or hexadecimal format, returns the same IP address in binary format.\n\n        ip2bin('192.168.1.24')\n        '11000000101010000000000100011000'\n    \n- bin2ip: Given an IP address in binary format returns the same IP address in either decimal or hexadecimal format.\n\n        bin2ip('11000000101010000000000100011000')\n        '192.168.1.24'\n    \n- in_subnet: Given a subnet and an IP will return True if the IP is in that subnet, will return False if otherwise.  Works for both IPv4 and IPv6.\n\n        in_subnet('192.168.1.24', '192.168.1.0/24')\n        True\n        in_subnet('192.168.1.24', '192.168.2.0/24')\n        False\n\n- overlap: Given two subnets two subnets will return True if they overlap or are identical.  Will return False if the subnets don't overlap.\n\n        overlap('172.16.0.0/12', '172.16.0.0/16')\n        True\n        overlap('172.16.0.0/12', '172.10.0.0/16')\n        False\n        \n- hex_range: Given the first and last hexadecimal values of a range returns a list of ReGex patterns to match each value of that range. Used in the toRegexv6 function.\n\n        hex_range('0000', 'aaaa')\n        hex_range('0000', 'aaaa')\n        ['[0-9a-f]{0,1}', '[0-9a-f]{0,1}[0-9a-f]{0,1}', '[0-9a-f]{1}[0-9a-f]{0,2}', '[1-9]{0,1}[0-9a-f]{0,3}', 'aaa[0-9a-a]{0,1}', 'aa[0-9a-9]{1}[0-9a-f]{0,1}', 'a[0-9a-9]{1}[0-9a-f]{0,2}']\n    \n- toRegexv4: Returns a RegEx pattern to match the given IPv4 subnet. Used in the toRegex function.\n\n        toRegexv4('192.168.1.0/14')\n        '192.[1][6][8-9].[0-9]{1,3}.[0-9]{1,3}|192.[1][7][0-1].[0-9]{1,3}.[0-9]{1,3}'\n    \n- toRegexv6: Returns a RegEx pattern to match the given IPv6 subnet. Used in the toRegex function.\n\n        toRegexv6('ac43:34f:45bc:2c::12/56')\n        'ac43:34f:45bc:[0-9a-f]{0,1}:.*|ac43:34f:45bc:[0-9a-f]{0,1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:[1-9a-e]{1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:f[0-9a-f]{0,1}:.*'\n\n- toRegex: Returns a RegEx pattern to match the given subnet.  Works for both IPv4 and IPv6.\n\n        toRegexv4('192.168.1.0/14')\n        '192.[1][6][8-9].[0-9]{1,3}.[0-9]{1,3}|192.[1][7][0-1].[0-9]{1,3}.[0-9]{1,3}'\n        toRegexv6('ac43:34f:45bc:2c::12/56')\n        'ac43:34f:45bc:[0-9a-f]{0,1}:.*|ac43:34f:45bc:[0-9a-f]{0,1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:[1-9a-e]{1}[0-9a-f]{0,1}:.*|ac43:34f:45bc:f[0-9a-f]{0,1}:.*'\n\n### License:\n\nBasic MIT license.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2018 The Python Packaging Authority  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A package for facilitating various IP and subnet operations.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/loicjamesmckeever/binip",
        "Issues": "https://github.com/loicjamesmckeever/binip/issues"
    },
    "split_keywords": [
        "ip",
        " network",
        " subnet"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38cd01606e1c84964349f9fcc8f12034fc37eef0b1c8e9e9c220fd16e29052ff",
                "md5": "a2f615fffd45c440109e863f2d4b349f",
                "sha256": "803c6c631906240f16d5302ca9c4395675dce32467c7a7720de4ead01ab0c905"
            },
            "downloads": -1,
            "filename": "binip-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a2f615fffd45c440109e863f2d4b349f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16268,
            "upload_time": "2024-04-16T17:32:01",
            "upload_time_iso_8601": "2024-04-16T17:32:01.919292Z",
            "url": "https://files.pythonhosted.org/packages/38/cd/01606e1c84964349f9fcc8f12034fc37eef0b1c8e9e9c220fd16e29052ff/binip-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "003e43df1456d7afc285fe3110d92f275a48d2a558f80c494547b5801d4caa45",
                "md5": "025a9f97a29d6331f58381fe46299cf7",
                "sha256": "8e63502bac0af606b894bbf214ceeba5cb4dd82c5458c660ccf3b9306a1339a0"
            },
            "downloads": -1,
            "filename": "binip-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "025a9f97a29d6331f58381fe46299cf7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14672,
            "upload_time": "2024-04-16T17:32:04",
            "upload_time_iso_8601": "2024-04-16T17:32:04.770934Z",
            "url": "https://files.pythonhosted.org/packages/00/3e/43df1456d7afc285fe3110d92f275a48d2a558f80c494547b5801d4caa45/binip-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-16 17:32:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "loicjamesmckeever",
    "github_project": "binip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "binip"
}
        
Elapsed time: 3.56903s