import os

if_path = "/sys/class/net"


class NetworkDevice:
    def __init__(self, mac, interface):
        self.mac = mac
        self.interface = interface


def get():
    for root, dirs, files in os.walk(if_path):
        for interface in dirs:
            mac_dir = os.path.join(root, interface, "address")
            mac_dir_exist = os.path.exists(mac_dir)
            wireless_dir = not os.path.exists(os.path.join(root, interface, "wireless"))
            if mac_dir_exist and interface != "lo" and wireless_dir:
                with open(mac_dir, "r") as f:
                    mac_address = f.readline().strip().upper()
                    if mac_address and len(mac_address) > 0:
                        return NetworkDevice(mac_address, interface)
