import re


def get_valid_ports() -> dict:
    """[Extract valid port codes from raw port values]

    Returns:
        dict: [dictionary including valid port as key, and its description as key value]
    """
    # Extract valid ports into a dictionary
    re_obj = re.compile("'(.*)'\s=\s'(.*)'") # '(\S{3})'\s=\s'(.*),\s{1}(\S{2}).*
    validPorts = {}
    with open('utils/port_code.py') as f:
         for data in f:
             match = re_obj.search(data)
             if match:
                 validPorts[match[1]] = match[2].strip()
    return validPorts