netsome


Namenetsome JSON
Version 0.3.25 PyPI version JSON
download
home_pagehttps://github.com/kuderr/netsome
SummaryThe one and only library to make your network code handsome
upload_time2024-11-10 15:06:12
maintainerNone
docs_urlNone
authorkuderr
requires_python<4.0,>=3.10
licenseX11-distribute-modifications-variant
keywords library network
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Netsome

[![pypi](https://img.shields.io/pypi/v/netsome.svg)](https://pypi.org/project/netsome/)
[![downloads](https://static.pepy.tech/badge/netsome)](https://www.pepy.tech/projects/netsome)
[![downloads](https://static.pepy.tech/badge/netsome/month)](https://www.pepy.tech/projects/netsome)
[![versions](https://img.shields.io/pypi/pyversions/netsome.svg)](https://github.com/kuderr/netsome)
[![license](https://img.shields.io/github/license/kuderr/netsome.svg)](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/ee/be/14474a91b5cc9ede3b8d46c9771dd16183d931c7f66ad661f623d92cc118/netsome-0.3.25.tar.gz",
    "platform": null,
    "description": "# Netsome\n\n[![pypi](https://img.shields.io/pypi/v/netsome.svg)](https://pypi.org/project/netsome/)\n[![downloads](https://static.pepy.tech/badge/netsome)](https://www.pepy.tech/projects/netsome)\n[![downloads](https://static.pepy.tech/badge/netsome/month)](https://www.pepy.tech/projects/netsome)\n[![versions](https://img.shields.io/pypi/pyversions/netsome.svg)](https://github.com/kuderr/netsome)\n[![license](https://img.shields.io/github/license/kuderr/netsome.svg)](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.25",
    "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": "c17fa4aa6aedc4542b45b409b58060d2b5aed7289c31a466c7b16cab24a0b2e7",
                "md5": "344d03389603e09254cdf199124e3fff",
                "sha256": "5df8de95012ff72350dcf980efc430e66f93b58e99d5be7f39f4f0c1071af76c"
            },
            "downloads": -1,
            "filename": "netsome-0.3.25-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "344d03389603e09254cdf199124e3fff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 16806,
            "upload_time": "2024-11-10T15:06:11",
            "upload_time_iso_8601": "2024-11-10T15:06:11.447409Z",
            "url": "https://files.pythonhosted.org/packages/c1/7f/a4aa6aedc4542b45b409b58060d2b5aed7289c31a466c7b16cab24a0b2e7/netsome-0.3.25-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eebe14474a91b5cc9ede3b8d46c9771dd16183d931c7f66ad661f623d92cc118",
                "md5": "44c9fef3a5e037b0b9ba2b694d6dfc8d",
                "sha256": "5684a1756a30d3672626dd2d2567bbb52ec691456b7f58abeb4bc90ca30e8f9d"
            },
            "downloads": -1,
            "filename": "netsome-0.3.25.tar.gz",
            "has_sig": false,
            "md5_digest": "44c9fef3a5e037b0b9ba2b694d6dfc8d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 12543,
            "upload_time": "2024-11-10T15:06:12",
            "upload_time_iso_8601": "2024-11-10T15:06:12.585442Z",
            "url": "https://files.pythonhosted.org/packages/ee/be/14474a91b5cc9ede3b8d46c9771dd16183d931c7f66ad661f623d92cc118/netsome-0.3.25.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-10 15:06:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kuderr",
    "github_project": "netsome",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "netsome"
}
        
Elapsed time: 1.33739s