# Netsome
[](https://pypi.org/project/netsome/)
[](https://www.pepy.tech/projects/netsome)
[](https://www.pepy.tech/projects/netsome)
[](https://github.com/kuderr/netsome)
[](https://github.com/kuderr/netsome/blob/master/LICENSE)
A Python library for working with common networking types and conversions, including IPv4 addresses/networks, MAC addresses, BGP ASNs, VLANs and network interfaces.
## Installation
```bash
pip install netsome
```
## Features
- IPv4 address and network manipulation (addresses, networks, interfaces)
- MAC address handling (MAC-48/EUI-48)
- BGP AS number conversions (asplain, asdot, asdotplus formats)
- VLAN ID validation and management
- Network interface name parsing and standardization
- Robust validation for all data types
- Type-safe implementation with proper error handling
## Basic Usage
```python
from netsome.types import (
IPv4Address,
IPv4Network,
IPv4Interface,
MacAddress,
ASN,
VID,
Community,
Interface,
)
# Create and manipulate IPv4 addresses
ipv4_addr = IPv4Address("192.168.1.1")
print(ipv4_addr.address) # "192.168.1.1"
print(ipv4_addr.cidr) # "192.168.1.1/32"
ipv4_net = IPv4Network("192.168.1.0/24")
print(ipv4_net.prefixlen) # 24
print(ipv4_net.netaddress) # "192.168.1.0"
ipv4_interface = IPv4Interface("192.168.1.1/24")
print(ipv4_interface.address) # "192.168.1.1"
print(ipv4_interface.network) # "192.168.1.0/24"
# Work with MAC addresses
mac = MacAddress("001122334455")
print(mac.is_unicast()) # True
print(mac.oui) # "001122"
# Handle BGP AS numbers
asn = ASN.from_asdot("64512.1")
print(asn.to_asplain()) # "4244897793"
# Work with BGP Communities
community = Community.from_str("65000:100")
print(str(community)) # "65000:100"
print(int(community)) # 4259840100
# Manage VLAN IDs
vid = VID(100)
print(vid.is_reserved()) # False
# Parse and work with network interface names
iface = Interface("eth0")
print(iface.type) # IFACE_TYPES.ETHERNET
print(iface.value) # "0"
print(iface.canonical_name) # "Ethernet0"
print(iface.abbreviated_name) # "Eth0"
```
# Authors
- Dmitriy Kudryavtsev - author - [kuderr](https://github.com/kuderr)
Raw data
{
"_id": null,
"home_page": "https://github.com/kuderr/netsome",
"name": "netsome",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "library, network",
"author": "kuderr",
"author_email": "dakudryavcev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e0/b4/0281104456832362b1d903cf3b9fa300d731f98e66fb7c56629f8a172b09/netsome-0.3.26.tar.gz",
"platform": null,
"description": "# Netsome\n\n[](https://pypi.org/project/netsome/)\n[](https://www.pepy.tech/projects/netsome)\n[](https://www.pepy.tech/projects/netsome)\n[](https://github.com/kuderr/netsome)\n[](https://github.com/kuderr/netsome/blob/master/LICENSE)\n\nA Python library for working with common networking types and conversions, including IPv4 addresses/networks, MAC addresses, BGP ASNs, VLANs and network interfaces.\n\n## Installation\n\n```bash\npip install netsome\n```\n\n## Features\n\n- IPv4 address and network manipulation (addresses, networks, interfaces)\n- MAC address handling (MAC-48/EUI-48)\n- BGP AS number conversions (asplain, asdot, asdotplus formats)\n- VLAN ID validation and management\n- Network interface name parsing and standardization\n- Robust validation for all data types\n- Type-safe implementation with proper error handling\n\n## Basic Usage\n\n```python\nfrom netsome.types import (\n IPv4Address,\n IPv4Network,\n IPv4Interface,\n MacAddress,\n ASN,\n VID,\n Community,\n Interface,\n)\n\n# Create and manipulate IPv4 addresses\nipv4_addr = IPv4Address(\"192.168.1.1\")\nprint(ipv4_addr.address) # \"192.168.1.1\"\nprint(ipv4_addr.cidr) # \"192.168.1.1/32\"\n\nipv4_net = IPv4Network(\"192.168.1.0/24\")\nprint(ipv4_net.prefixlen) # 24\nprint(ipv4_net.netaddress) # \"192.168.1.0\"\n\nipv4_interface = IPv4Interface(\"192.168.1.1/24\")\nprint(ipv4_interface.address) # \"192.168.1.1\"\nprint(ipv4_interface.network) # \"192.168.1.0/24\"\n\n# Work with MAC addresses\nmac = MacAddress(\"001122334455\")\nprint(mac.is_unicast()) # True\nprint(mac.oui) # \"001122\"\n\n# Handle BGP AS numbers\nasn = ASN.from_asdot(\"64512.1\")\nprint(asn.to_asplain()) # \"4244897793\"\n\n# Work with BGP Communities\ncommunity = Community.from_str(\"65000:100\")\nprint(str(community)) # \"65000:100\"\nprint(int(community)) # 4259840100\n\n# Manage VLAN IDs\nvid = VID(100)\nprint(vid.is_reserved()) # False\n\n# Parse and work with network interface names\niface = Interface(\"eth0\")\nprint(iface.type) # IFACE_TYPES.ETHERNET\nprint(iface.value) # \"0\"\nprint(iface.canonical_name) # \"Ethernet0\"\nprint(iface.abbreviated_name) # \"Eth0\"\n```\n\n# Authors\n\n- Dmitriy Kudryavtsev - author - [kuderr](https://github.com/kuderr)\n",
"bugtrack_url": null,
"license": "X11-distribute-modifications-variant",
"summary": "The one and only library to make your network code handsome",
"version": "0.3.26",
"project_urls": {
"Bug Tracker": "https://github.com/kuderr/netsome/issues",
"Homepage": "https://github.com/kuderr/netsome",
"Repository": "https://github.com/kuderr/netsome"
},
"split_keywords": [
"library",
" network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ff81bc5873c959bb4bc890b29170047400f69c92d9dfacf8d7953861e007f3c0",
"md5": "583018a59d6b91183a4236613f11ba4e",
"sha256": "73ece92a178f8da26fab5d2d165d17a8072020a740870918d77474e984927883"
},
"downloads": -1,
"filename": "netsome-0.3.26-py3-none-any.whl",
"has_sig": false,
"md5_digest": "583018a59d6b91183a4236613f11ba4e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 16807,
"upload_time": "2025-01-03T18:36:15",
"upload_time_iso_8601": "2025-01-03T18:36:15.032867Z",
"url": "https://files.pythonhosted.org/packages/ff/81/bc5873c959bb4bc890b29170047400f69c92d9dfacf8d7953861e007f3c0/netsome-0.3.26-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e0b40281104456832362b1d903cf3b9fa300d731f98e66fb7c56629f8a172b09",
"md5": "693bf233ddfa8f3df1899bbfefdd6707",
"sha256": "86af664a00a59bbee104cc47edfa73a940c66bb3f2a451b02bc419785d200d54"
},
"downloads": -1,
"filename": "netsome-0.3.26.tar.gz",
"has_sig": false,
"md5_digest": "693bf233ddfa8f3df1899bbfefdd6707",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 12548,
"upload_time": "2025-01-03T18:36:17",
"upload_time_iso_8601": "2025-01-03T18:36:17.368917Z",
"url": "https://files.pythonhosted.org/packages/e0/b4/0281104456832362b1d903cf3b9fa300d731f98e66fb7c56629f8a172b09/netsome-0.3.26.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-03 18:36:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kuderr",
"github_project": "netsome",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "netsome"
}