def is_usb_serial(device, args):
    """Checks device to see if its a USB Serial device.

    The caller already filters on the subsystem being "tty".

    If serial_num or vendor is provided, then it will further check to
    see if the serial number and vendor of the device also matches.

    """

    if "ID_VENDOR" not in device:
        return False
    if args.vid is not None:
        if device["ID_VENDOR_ID"] != args.vid:
            return False
    if args.pid is not None:
        if device["ID_MODEL_ID"] != args.pid:
            return False
    if args.vendor is not None:
        if not device["ID_VENDOR"].startswith(args.vendor):
            return False
    if args.serial is not None:
        if not device["ID_SERIAL_SHORT"].startswith(args.serial):
            return False
    return True