{ "info": { "author": "Michael Henry a.k.a. neoCrimeLabs", "author_email": "mhenry@neocri.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Topic :: System :: Networking" ], "description": "================\nnetwork_dict 0.1\n================\n\nSummary\n=======\n\nnetwork_dict creates a network subnet based dictionary that returns the most specific subnet(s) for a given IP. It will work equally with both IPv4 and IPv6.\n\nThere's a few more simple bells and whistles to make the library useful in different circumstances.\n\nThis is a case where examples speak louder than words...\n\nSimple Example\n--------------\n\n.. code:: python\n\n from network_dict import NetworkDict\n\n networks = {\n '0.0.0.0/0': 'Everything',\n '10.0.0.0/8': 'Office',\n '10.1.0.0/16': 'Region 1',\n '10.1.1.0/255.255.255.0': 'City 1' # Can take multiple netmasks\n }\n\n ns = NetworkDict(networks)\n\n >>> nd['10.1.1.1']\n 'City 1'\n \n >>> nd.firstHit = False\n # Return all matching values in a list\n # Results are in order, most to least specific\n >>> nd['10.1.1.1']\n ['City 1', 'Region 1', 'Office', 'Everything']\n\n >>> nd.format = both\n # return both the subnet and value in a tuple\n >>> nd['10.1.1.1']\n [('10.1.1.0/24', 'City 1'), ('10.1.0.0/16', 'Region 1'), ('10.0.0.0/8', 'Office'), ('0.0.0.0/0', 'Everything')]\n\n >>> nd.format = key\n # return just the subnet address\n >>> nd['10.1.1.1']\n ['10.1.1.0/24', '10.1.0.0/16', '10.0.0.0/8', '0.0.0.0/0']\n\nAdding Subnets\n--------------\n\n.. code:: python\n\n >>> nd['192.168.1.1']\n ['0.0.0.0/0']\n # If 0.0.0.0/0 is not set, will return KeyError exception\n >>> nd['192.168.1.1/16'] = 'Home'\n >>> nd['192.168.1.1']\n ['192.168.0.0/16', '0.0.0.0/16']\n # Note that the key was normalized to a proper subnet\n\n\nHosts and /32 prefixes\n----------------------\n\n.. code:: python\n\n >>> nd['10.1.1.1'] = 'Router'\n >>> nd['10.1.1.1']\n ['10.1.1.0/24', '10.1.0.0/16', '10.0.0.0/8', '0.0.0.0/0']\n # Hosts are ignored by default\n >>> nd.ignoreHosts = False\n >>> nd['10.1.1.1'] = 'Router'\n ['10.1.1.1/32', '10.1.1.0/24', '10.1.0.0/16', '10.0.0.0/8', '0.0.0.0/0']\n\nIPv6 Subnets\n------------\n\n.. code:: python\n\n >>> nd['::1']\n Traceback (most recent call last):\n File \"\", line 1, in \n KeyError: No matching networks found, and no default network set\n # we didn't set '::/0', which is different from the '0.0.0.0/0' which is already set\n >>> nd['::1/128'] = 'Localhost'\n # Note: /128 is a hostmask, so will be ignored if ignoreHosts = True (default)\n >>> nd['::1']\n ['::1/128']\n\nSetting options at creation\n---------------------------\n\n.. code:: python\n\n >>> nd = NetworkDict(format = 'both', firstHit = False, ignoreHosts = True)\n # Returns an empty NetworkDict object, but with default options set\n\n\nRequirements\n============\n\n* Tested on python 2.8\n* netaddr library\n\nInstallation\n============\n\nVia pip or easy_install\n-----------------------\n\n.. code:: bash\n\n $ sudo pip install network_dict # If you prefer PIP\n\n $ sudo easy_install network_dict # If you prefer easy_install\n\nManual installation\n-------------------\n\n.. code:: bash\n\n $ git clone https://github.com/neoCrimeLabs/python-network_dict.git\n $ cd python-network_dict\n $ sudo python setup.py install\n\n\nConditions of Use\n=================\n\nI wrote this library for my own use, but realized others may find it useful.\n\nUnfortunately I cannot guarentee any active support, but will do my best as time\npermits. That said, I'll happily accept push requests with suitable changes\nthat address the general audience of this library.\n\nPut simply, use this at your own risk. If it works, great! If not, I may not\nbe able to help you. If you fix anything, however, please push it back and I'll\nlikely accept it. :-)\n\nAlso, if you use this library in your package, tool, or comercial software, let\nme know, and I'll list it here!", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/neoCrimeLabs/python-network_dict", "keywords": null, "license": "LGPLv2.1", "maintainer": null, "maintainer_email": null, "name": "network_dict", "package_url": "https://pypi.org/project/network_dict/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/network_dict/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/neoCrimeLabs/python-network_dict" }, "release_url": "https://pypi.org/project/network_dict/0.1/", "requires_dist": null, "requires_python": null, "summary": "network_dict creates a network subnet based dictionary that returns the most specific subnet(s) for a given IP.", "version": "0.1" }, "last_serial": 1189490, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "6b910b4338b98396c4cd48c57e16ce40", "sha256": "0eef2eb77c4cc7a7c75bb453dc3c2613db89a36393d3440f07683423b89e87ec" }, "downloads": -1, "filename": "network_dict-0.1.tar.gz", "has_sig": false, "md5_digest": "6b910b4338b98396c4cd48c57e16ce40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15473, "upload_time": "2014-08-13T17:56:58", "url": "https://files.pythonhosted.org/packages/ec/9c/ee0d172cc4f96e269e01fbb5d7458e8238934eec7b9e41d882a3356a2243/network_dict-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6b910b4338b98396c4cd48c57e16ce40", "sha256": "0eef2eb77c4cc7a7c75bb453dc3c2613db89a36393d3440f07683423b89e87ec" }, "downloads": -1, "filename": "network_dict-0.1.tar.gz", "has_sig": false, "md5_digest": "6b910b4338b98396c4cd48c57e16ce40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15473, "upload_time": "2014-08-13T17:56:58", "url": "https://files.pythonhosted.org/packages/ec/9c/ee0d172cc4f96e269e01fbb5d7458e8238934eec7b9e41d882a3356a2243/network_dict-0.1.tar.gz" } ] }