{ "info": { "author": "Jeff Ferland", "author_email": "jeff@storyinmemo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Plugins", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking" ], "description": "IPy - class and tools for handling of IPv4 and IPv6 addresses and networks.\n\nWebsite: https://github.com/autocracy/python-ipy/\n\nPresentation of the API\n=======================\n\nThe IP class allows a comfortable parsing and handling for most\nnotations in use for IPv4 and IPv6 addresses and networks. It was\ngreatly inspired by RIPE's Perl module NET::IP's interface but\ndoesn't share the implementation. It doesn't share non-CIDR netmasks,\nso funky stuff like a netmask of 0xffffff0f can't be done here. ::\n\n >>> from IPy import IP\n >>> ip = IP('127.0.0.0/30')\n >>> for x in ip:\n ... print(x)\n ...\n 127.0.0.0\n 127.0.0.1\n 127.0.0.2\n 127.0.0.3\n >>> ip2 = IP('0x7f000000/30')\n >>> ip == ip2\n 1\n >>> ip.reverseNames()\n ['0.0.0.127.in-addr.arpa.', '1.0.0.127.in-addr.arpa.', '2.0.0.127.in-addr.arpa.', '3.0.0.127.in-addr.arpa.']\n >>> ip.reverseName()\n '0-3.0.0.127.in-addr.arpa.'\n >>> ip.iptype()\n 'LOOPBACK'\n\n\nSupports most IP address formats\n================================\n\nIt can detect about a dozen different ways of expressing IP addresses\nand networks, parse them and distinguish between IPv4 and IPv6 addresses: ::\n\n >>> IP('10.0.0.0/8').version()\n 4\n >>> IP('::1').version()\n 6\n\nIPv4 addresses\n--------------\n\n::\n\n >>> print(IP(0x7f000001))\n 127.0.0.1\n >>> print(IP('0x7f000001'))\n 127.0.0.1\n >>> print(IP('127.0.0.1'))\n 127.0.0.1\n >>> print(IP('10'))\n 10.0.0.0\n\nIPv6 addresses\n--------------\n\n::\n\n >>> print(IP('1080:0:0:0:8:800:200C:417A'))\n 1080::8:800:200c:417a\n >>> print(IP('1080::8:800:200C:417A'))\n 1080::8:800:200c:417a\n >>> print(IP('::1'))\n ::1\n >>> print(IP('::13.1.68.3'))\n ::d01:4403\n\nNetwork mask and prefixes\n-------------------------\n\n::\n\n >>> print(IP('127.0.0.0/8'))\n 127.0.0.0/8\n >>> print(IP('127.0.0.0/255.0.0.0'))\n 127.0.0.0/8\n >>> print(IP('127.0.0.0-127.255.255.255'))\n 127.0.0.0/8\n\n\nDerive network address\n===========================\n\nIPy can transform an IP address into a network address by applying the given\nnetmask: ::\n\n >>> print(IP('127.0.0.1/255.0.0.0', make_net=True))\n 127.0.0.0/8\n\nThis can also be done for existing IP instances: ::\n\n >>> print(IP('127.0.0.1').make_net('255.0.0.0'))\n 127.0.0.0/8\n\n\nConvert address to string\n=========================\n\nNearly all class methods which return a string have an optional\nparameter 'wantprefixlen' which controls if the prefixlen or netmask\nis printed. Per default the prefilen is always shown if the network\ncontains more than one address: ::\n\n wantprefixlen == 0 / None don't return anything 1.2.3.0\n wantprefixlen == 1 /prefix 1.2.3.0/24\n wantprefixlen == 2 /netmask 1.2.3.0/255.255.255.0\n wantprefixlen == 3 -lastip 1.2.3.0-1.2.3.255\n\nYou can also change the defaults on an per-object basis by fiddling with\nthe class members:\n\n- NoPrefixForSingleIp\n- WantPrefixLen\n\nExamples of string conversions: ::\n\n >>> IP('10.0.0.0/32').strNormal()\n '10.0.0.0'\n >>> IP('10.0.0.0/24').strNormal()\n '10.0.0.0/24'\n >>> IP('10.0.0.0/24').strNormal(0)\n '10.0.0.0'\n >>> IP('10.0.0.0/24').strNormal(1)\n '10.0.0.0/24'\n >>> IP('10.0.0.0/24').strNormal(2)\n '10.0.0.0/255.255.255.0'\n >>> IP('10.0.0.0/24').strNormal(3)\n '10.0.0.0-10.0.0.255'\n >>> ip = IP('10.0.0.0')\n >>> print(ip)\n 10.0.0.0\n >>> ip.NoPrefixForSingleIp = None\n >>> print(ip)\n 10.0.0.0/32\n >>> ip.WantPrefixLen = 3\n >>> print(ip)\n 10.0.0.0-10.0.0.0\n\nWork with multiple networks\n===========================\n\nSimple addition of neighboring netblocks that can be aggregated will yield\na parent network of both, but more complex range mapping and aggregation\nrequires is available with the ``IPSet`` class which will hold any number of\nunique address ranges and will aggregate overlapping ranges. ::\n\n >>> from IPy import IP, IPSet\n >>> IP('10.0.0.0/22') - IP('10.0.2.0/24')\n IPSet([IP('10.0.0.0/23'), IP('10.0.3.0/24')])\n >>> IPSet([IP('10.0.0.0/23'), IP('10.0.3.0/24'), IP('10.0.2.0/24')])\n IPSet([IP('10.0.0.0/22')])\n >>> s = IPSet([IP('10.0.0.0/22')])\n >>> s.add(IP('192.168.1.0/29'))\n >>> s\n IPSet([IP('10.0.0.0/22'), IP('192.168.1.0/29')])\n >>> s.discard(IP('192.168.1.2'))\n >>> s\n IPSet([IP('10.0.0.0/22'), IP('192.168.1.0/31'), IP('192.168.1.3'), IP('192.168.1.4/30')])\n\n``IPSet`` supports the ``set`` method ``isdisjoint``: ::\n\n >>> s.isdisjoint(IPSet([IP('192.168.0.0/16')]))\n False\n >>> s.isdisjoint(IPSet([IP('172.16.0.0/12')]))\n True\n\n``IPSet`` supports intersection: ::\n\n >>> s & IPSet([IP('10.0.0.0/8')])\n IPSet([IP('10.0.0.0/22')])\n\nCompatibility and links\n=======================\n\nIPy 1.00 works on Python version 2.6 - 3.7.\n\nThe IP module should work in Python 2.5 as long as the subtraction operation\nis not used. IPSet requires features of the collecitons class which appear\nin Python 2.6, though they can be backported.\n\nEratta\n======\n\nWhen using IPv6 addresses, it is best to compare using ``IP().len()``\ninstead of ``len(IP)``. Addresses with an integer value > 64 bits can break\nthe 2nd method. See http://stackoverflow.com/questions/15650878 for more\ninfo.\n\nFuzz testing for ``IPSet`` will throw spurious errors when the ``IPSet`` module\ncombines two smaller prefixes into a larger prefix that matches the random\nprefix tested against.\n\nThis Python module is under BSD license: see COPYING file.\n\nFurther Information might be available at:\nhttps://github.com/autocracy/python-ipy\n\nWhat's new\n==========\n\nVersion 1.00 (2019-02-27)\n * Fix IPv6 string interpretation for small ints\n * Various Python3 language fixes\n * consider 127.0 range LOOPBACK not PRIVATE\n\nVersion 0.83 (2015-04-04)\n------------\n * Add carrier grade NAT ranges\n * Unbreak lots of packing systems by not having a letter in the release version\n\nVersion 0.82a (2014-10-07)\n------------\n * Fix version numbers in files\n * Correct x.next() -> next(x) python3 compatability\n\nVersion 0.82 (2014-10-06)\n------------\n\n * Add support for array slices\n * Add __and__ and isdisjoint for IPSet\n * Fix a bug in IPSet where contains may incorrectly return false\n * Added some fuzz testing\n\nVersion 0.81 (2013-04-08)\n------------\n\n * Correct reverseName() for IPv6 addresses, so IP('::1').reverseName() returns correct.\n * Add network mask awareness to v46map()\n * Fix Python 3 errors in IPSet class\n * Make IPSet base class be object when MutableSet isn't available, fixing\n errors in Python 2.5\n\nVersion 0.80 (2013-03-26)\n------------\n\n * Drop support of Python older than 2.4\n * Python 3 does not need 2to3 conversion anymore (same code base)\n * Fix adding of non-adjacent networks:\n 192.168.0.0/24 + 192.168.255.0/24 made 192.168.0.0/23\n * Fix adding networks that don't create a valid subnet:\n 192.168.1.0/24 + 192.168.2.0/24 made 192.168.1.0/23\n * Fix adding with an IPv6 address where .int() was < 32 bits made IPy believe it\n was an IPv4 address:\n ::ffff:0/112 + ::1:0:0/112 made 255.255.0.0/111\n * Add support of IPSets\n * Add support for subtracting a network range\n * Prevent IPv4 and IPv6 ranges from saying they contain each other\n * Add a .v46map() method to convert mapped address ranges\n such as IP('::ffff:192.168.1.1'); RFC 4291\n * Change sort order to more natural: \n IPv4 before IPv6; less-specific prefixes first (/0 before /32)\n\n\nVersion 0.76 (2013-03-19)\n-------------------------\n\n * ip == other and ip != other doesn't fail with an exception anymore if other\n is not a IP object\n * Add IP.get_mac() method: get the 802.3 MAC address from IPv6 RFC 2464\n address.\n * Fix IP('::/0')[0]: return an IPv6 instead of an IPv4 address\n\nVersion 0.75 (2011-04-12)\n-------------------------\n\n * IP('::/0').netmask() gives IP('::') instead of IP('0.0.0.0')\n\nVersion 0.74 (2011-02-16)\n-------------------------\n\n * Fix tests for Python 3.1 and 3.2\n * ip.__nonzero__() and (ipa in ipb) return a bool instead of 0 or 1\n * IP('0.0.0.0/0') + IP('0.0.0.0/0') raises an error, fix written by Arfrever\n\nVersion 0.73 (2011-02-15)\n-------------------------\n\n * Support Python 3: setup.py runs 2to3\n * Update the ranges for IPv6 IPs\n * Fix reverseName() and reverseNames() for IPv4 in IPv6 addresses\n * Drop support of Python < 2.5\n\nVersion 0.72 (2010-11-23)\n-------------------------\n\n * Include examples and MANIFEST.in in source build (add them to\n MANIFEST.in)\n * Remove __rcsid__ constant from IPy module\n\nVersion 0.71 (2010-10-01)\n-------------------------\n\n * Use xrange() instead of range()\n * Use isinstance(x, int) instead of type(x) == types.IntType\n * Prepare support of Python3 (use integer division: x // y)\n * Fix IP(long) constructor: ensure that the address is not too large\n * Constructor raise a TypeError if the type is not int, long,\n str or unicode\n * 223.0.0.0/8 is now public (belongs to APNIC)\n\nVersion 0.70 (2009-10-29)\n-------------------------\n\n * New \"major\" version because it may break compatibility\n * Fix __cmp__(): IP('0.0.0.0/0') and IP('0.0.0.0') are not equal\n * Fix IP.net() of the network \"::/0\": \"::\" instead of \"0.0.0.0\".\n IPy 0.63 should fix this bug, but it wasn't.\n\nVersion 0.64 (2009-08-19)\n-------------------------\n\n * Create MANIFEST.in to fix setup.py bdist_rpm, fix by Robert Nickel\n\nVersion 0.63 (2009-06-23)\n-------------------------\n\n * Fix formatting of \"IPv4 in IPv6\" network, eg. IP('::ffff:192.168.10.0/120'),\n the netmask (\"/120\" in the example) was missing!\n\nVersion 0.62 (2008-07-15)\n-------------------------\n\n * Fix reverse DNS of IPv6 address: use \".ip6.arpa.\" suffix instead of\n deprecated \".ip6.int.\" suffix\n\nVersion 0.61 (2008-06-12)\n-------------------------\n\n * Patch from Aras Vaichas allowing the [-1] operator\n to work with an IP object of size 1.\n\nVersion 0.60 (2008-05-16)\n-------------------------\n\n * strCompressed() formats '::ffff:a.b.c.d' correctly\n * Use strCompressed() instead of strFullsize() to format IP addresses,\n ouput is smarter with IPv6 address\n * Remove check_addr_prefixlen because it generates invalid IP address", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/autocracy/python-ipy", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/autocracy/python-ipy", "keywords": "ipv4 ipv6 netmask", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "IPy", "package_url": "https://pypi.org/project/IPy/", "platform": "", "project_url": "https://pypi.org/project/IPy/", "project_urls": { "Download": "https://github.com/autocracy/python-ipy", "Homepage": "https://github.com/autocracy/python-ipy" }, "release_url": "https://pypi.org/project/IPy/1.00/", "requires_dist": null, "requires_python": "", "summary": "Class and tools for handling of IPv4 and IPv6 addresses and networks", "version": "1.00" }, "last_serial": 4876786, "releases": { "0.73": [ { "comment_text": "", "digests": { "md5": "1fc9b08a6b42ee941fdbd56b6dc9937c", "sha256": "d6e4f8f29be0515ee74433a60c9638cb5b1fbb798de0ef35846c97f5834da871" }, "downloads": -1, "filename": "IPy-0.73.tar.gz", "has_sig": false, "md5_digest": "1fc9b08a6b42ee941fdbd56b6dc9937c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26373, "upload_time": "2011-02-15T01:25:19", "url": "https://files.pythonhosted.org/packages/bd/52/84d6f1dbb84b71409b64f8a807e4075169ed275756a357bf5b83da6042b7/IPy-0.73.tar.gz" } ], "0.74": [ { "comment_text": "", "digests": { "md5": "f4f7ddc7c5e55a47222a5cc6c0a87b6d", "sha256": "5d6abb870c25f946c45c35cf50e66155598660f2765b35cb12e36ed5223c2b89" }, "downloads": -1, "filename": "IPy-0.74.tar.gz", "has_sig": false, "md5_digest": "f4f7ddc7c5e55a47222a5cc6c0a87b6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27016, "upload_time": "2011-02-16T00:04:57", "url": "https://files.pythonhosted.org/packages/e4/6f/05372dbf0dda125b8ad5da17d18859fe2b587bc321b5d15ecc5b83fca48e/IPy-0.74.tar.gz" } ], "0.75": [ { "comment_text": "", "digests": { "md5": "d56716a3d8c77fe8539b6e90c88010bd", "sha256": "0fa14af4792cc0b6f61cb5a1cd8fbdf7ddbaa6864ef82681021b750e9e6b2b61" }, "downloads": -1, "filename": "IPy-0.75.tar.gz", "has_sig": false, "md5_digest": "d56716a3d8c77fe8539b6e90c88010bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28459, "upload_time": "2011-04-12T13:59:07", "url": "https://files.pythonhosted.org/packages/1e/88/b5a29c13e55c71d2a133d0dd17f65565b9bc500fa61d8a49f47098c26bec/IPy-0.75.tar.gz" } ], "0.76": [ { "comment_text": "", "digests": { "md5": "5b8dc85b39b11a7c2d21fe047fbc4482", "sha256": "b19441f3e311deb298a1ec7a16a3ce0d09b0ffde69ce3d608f59ec8481b3a6af" }, "downloads": -1, "filename": "IPy-0.76.tar.gz", "has_sig": false, "md5_digest": "5b8dc85b39b11a7c2d21fe047fbc4482", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29139, "upload_time": "2013-03-19T01:50:40", "url": "https://files.pythonhosted.org/packages/4e/3c/1ea6908d66e0edb3eb9c02345d6c473c5eef828a29b2a83c41182ab36897/IPy-0.76.tar.gz" } ], "0.80": [ { "comment_text": "", "digests": { "md5": "3ac024861a8ca833b3f041d0fe2ce04c", "sha256": "03f9491302e08f1355dbeccd94a1df851616f8cd1edd3a7e41f01aaf80d0f53c" }, "downloads": -1, "filename": "IPy-0.80.tar.gz", "has_sig": false, "md5_digest": "3ac024861a8ca833b3f041d0fe2ce04c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29621, "upload_time": "2013-03-26T21:56:07", "url": "https://files.pythonhosted.org/packages/5a/08/c03eced4f173d795c3d3276e3d3fcec2fa1c3635fa21a1243cc2868c6143/IPy-0.80.tar.gz" } ], "0.81": [ { "comment_text": "", "digests": { "md5": "7a305c0b60950a9a90c89e9a6f9e06f4", "sha256": "4bc17a9b5e72e893a034e77193b82c2bc321ddf8d8c345281f2bb81bb007b939" }, "downloads": -1, "filename": "IPy-0.81.tar.gz", "has_sig": false, "md5_digest": "7a305c0b60950a9a90c89e9a6f9e06f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32318, "upload_time": "2013-04-08T21:25:11", "url": "https://files.pythonhosted.org/packages/08/c0/8dde3aa805abdaff91a4a06c3cdc1f789547af80750560211d7cf442e1b7/IPy-0.81.tar.gz" } ], "0.82": [ { "comment_text": "", "digests": { "md5": "0625e884df8bde533b54a88c85cf5029", "sha256": "97f61708fe1f1b57373f40397d0929d59f6fd210a7f79242ef2456cd6a1b7c4a" }, "downloads": -1, "filename": "IPy-0.82.tar.gz", "has_sig": false, "md5_digest": "0625e884df8bde533b54a88c85cf5029", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31544, "upload_time": "2014-10-06T04:30:11", "url": "https://files.pythonhosted.org/packages/b4/ed/65e847385b72d91845d60ca5c552709abc825a783a0ba19096bf03bb8a8f/IPy-0.82.tar.gz" } ], "0.82a": [ { "comment_text": "", "digests": { "md5": "dbcd7bf3e7da1039aa6ffa436f5410ff", "sha256": "edaaa5344893437aa6c1eb9c4ca966eb4b8c071761793839c7b4fc2a837fbeec" }, "downloads": -1, "filename": "IPy-0.82a.tar.gz", "has_sig": false, "md5_digest": "dbcd7bf3e7da1039aa6ffa436f5410ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31588, "upload_time": "2014-10-07T17:24:15", "url": "https://files.pythonhosted.org/packages/f9/0a/30fe2ad5b5ba867bbf7f2c53d117007ac388c3fa84cb476d5dbad0b8a2a3/IPy-0.82a.tar.gz" } ], "0.83": [ { "comment_text": "", "digests": { "md5": "7b8c6eb4111b15aea31b67108e769712", "sha256": "61da5a532b159b387176f6eabf11946e7458b6df8fb8b91ff1d345ca7a6edab8" }, "downloads": -1, "filename": "IPy-0.83.tar.gz", "has_sig": false, "md5_digest": "7b8c6eb4111b15aea31b67108e769712", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31816, "upload_time": "2015-04-08T04:38:07", "url": "https://files.pythonhosted.org/packages/88/28/79162bfc351a3f1ab44d663ab3f03fb495806fdb592170990a1568ffbf63/IPy-0.83.tar.gz" } ], "1.00": [ { "comment_text": "", "digests": { "md5": "1a90c68174234672241a7e60c7ea0fb9", "sha256": "2f2bf658a858d43868d8a4352b3889cf78c66e2ce678b300dcf518c9149ba621" }, "downloads": -1, "filename": "IPy-1.00.tar.gz", "has_sig": false, "md5_digest": "1a90c68174234672241a7e60c7ea0fb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35324, "upload_time": "2019-02-28T00:20:29", "url": "https://files.pythonhosted.org/packages/e1/66/b6dd22472bb027556849876beae2dd4dca3a4eaf2dd3039277b4edb8c6af/IPy-1.00.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1a90c68174234672241a7e60c7ea0fb9", "sha256": "2f2bf658a858d43868d8a4352b3889cf78c66e2ce678b300dcf518c9149ba621" }, "downloads": -1, "filename": "IPy-1.00.tar.gz", "has_sig": false, "md5_digest": "1a90c68174234672241a7e60c7ea0fb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35324, "upload_time": "2019-02-28T00:20:29", "url": "https://files.pythonhosted.org/packages/e1/66/b6dd22472bb027556849876beae2dd4dca3a4eaf2dd3039277b4edb8c6af/IPy-1.00.tar.gz" } ] }