import os

demi_path = "/sys/devices/virtual/dmi/id"


class Motherboard:
    def __init__(self, vendor, name, version):
        self.vendor = vendor
        self.name = name
        self.version = version


def readfile(f_path):
    with open(f_path, "r") as f:
        return f.readline().strip()


def get():
    vendor = None
    name = None
    version = None
    vendor_path = demi_path + "/board_vendor"
    name_path = demi_path + "/board_name"
    version_path = demi_path + "/board_version"

    if os.path.isfile(os.path.abspath(vendor_path)):
        vendor = readfile(vendor_path)
    if os.path.isfile(os.path.abspath(name_path)):
        name = readfile(name_path)
    if os.path.isfile(os.path.abspath(version_path)):
        version = readfile(version_path)

    return Motherboard(vendor, name, version)
