eui48_bit_distance package¶
Calculate distance in bits between EUI-48 (a.k.a. 48-bit MAC) strings.
- eui48_bit_distance.check_eui48(a: str, /) bool¶
Check if input is a EUI-48 string.
- Returns:
Trueif a is a EUI-48 string, otherwiseFalse.
- eui48_bit_distance.int_to_eui48(i: int, /) str¶
Convert int into EUI-48 string.
- Raises:
ValueError – If the provided value cannot be represented by EUI-48.
- Returns:
i converted from
intinto EUI-48 string.
- eui48_bit_distance.eui48_to_int(a: str, /) int¶
Convert EUI-48 string into int.
- Returns:
a converted from EUI-48 string into
int.
- eui48_bit_distance.eui48_bit_distance(a: str, b: str, /) int¶
Calculate bit distance between two EUI-48 strings.
- Returns:
Amount of bits that are different between a and b.
- eui48_bit_distance.eui48_find_similar(a: str, iterable: Iterable[str], /, *, cutoff: int = 8) list[tuple[int, str]]¶
Return EUI-48 strings and their distances from reference EUI-48 string.
This function measures and orders output by the distances between a and every string in iterable. To reduce the number of elements in the output, it also drops inputs that have distance greater than cutoff.
- Returns:
A list of 2-tuples
(distance, EUI-48 string).