Simplify MAC bytes to str logic
Use Python's print micro-language for converting bytes representing a
MAC address to a human-readable string.
Change-Id: I43b6bc5a61a3f6554d6ef8266e198377ca0419f8
Reviewed-on: https://fuchsia-review.googlesource.com/c/antlion/+/921074
Fuchsia-Auto-Submit: Sam Balana <sbalana@google.com>
Reviewed-by: Jonathan Chang <jnchang@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
diff --git a/packages/antlion/utils.py b/packages/antlion/utils.py
index b4e8aa0..050190e 100755
--- a/packages/antlion/utils.py
+++ b/packages/antlion/utils.py
@@ -1901,15 +1901,8 @@
string, mac address
e.g. '12:34:56:78:9a:bc'
"""
- hex_list = []
- for octet in mac_addr_list:
- hex_octet = hex(octet)[2:]
- if octet < 16:
- hex_list.append(f"0{hex_octet}")
- else:
- hex_list.append(hex_octet)
-
- return ":".join(hex_list)
+ # Print each octet as hex, right justified, width of 2, and fill with "0".
+ return ":".join([f"{octet:0>2x}" for octet in mac_addr_list])
def get_fuchsia_mdns_ipv6_address(device_mdns_name):