Ejemplo n.º 1
0
def _get_index_of_first_matching_preferable_pattern(
        pi: QtSerialPort.QSerialPortInfo) -> typing.Optional[int]:
    for idx, (vendor_wildcard, product_wildcard
              ) in enumerate(_PREFERABLE_VENDOR_PRODUCT_PATTERNS):
        vendor_match = fnmatch.fnmatch(pi.manufacturer().lower(),
                                       vendor_wildcard.lower())
        product_match = fnmatch.fnmatch(pi.description().lower(),
                                        product_wildcard.lower())
        if vendor_match and product_match:
            return idx