Working with network MAC addresses
Project description
macaddr
As a network engineer you many have to deal with MAC address values. In some cases a network operating system wants the MAC address in a particular format. The following are common formats:
* aa:bb:cc:dd:ee:ff
* aabb-ccdd-eeff
* aabb.ccdd.eeff
As well as their upper-case variants, AA:BB:CC:DD:EE:FF for example.
This package provides the MacAddress
class definition and a supporting format
method that allows you to develop programs using a MAC address in different formats.
Installation
pip install macaddr
Usage
By default the MacAddress is formated in the "2 byte colon separated" format.
from macaddr import MacAddress
mac = MacAddress("aabb.ccdd.eeff")
print(mac)
aa:bb:cc:dd:ee:ff
You can obtain differnt formats using the format
method.
from macaddr import MacAddress
mac = MacAddress("aabb.ccdd.eeff")
print(mac.format(size=4, sep='-', to_case=str.upper))
AABB-CCDD-EEFF
The format
method values are cached so that repeated calls to format
with
the same arguments return the cached value. For example, if you had a network
of 1000 devices, 500 of them required the "2-colon" format and 500 of them
required the "4-dot" format, then these two formats are only computed twice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file macaddr-2.1.tar.gz
.
File metadata
- Download URL: macaddr-2.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07bb34404774719284b336c8d920ec29a49c948e2351ed357d6ed64e2533ae90 |
|
MD5 | eb14ee0da606c6af6855a0a871916014 |
|
BLAKE2b-256 | 5cf9264e433ffd3046106be8fd953fc86237b87e7da9c5622bf7c188b9ffd66d |
File details
Details for the file macaddr-2.1-py3-none-any.whl
.
File metadata
- Download URL: macaddr-2.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ef79bf0b451114f76b7e329bbdd134a6b2ca63d6e5aae72f990ea2a33d80c3 |
|
MD5 | 0df6152606c4b3faaa67634da5fc1fe2 |
|
BLAKE2b-256 | af0739cd975abb97f8bdcc68fd22dfc094db444946e7593976beb92bca8d11b2 |