File: //usr/lib/python3.6/site-packages/usb/__pycache__/util.cpython-36.opt-1.pyc
3
�~�V0 � @ s d Z dZddlZddlZddlmZ ddljZdZdZ dZ
dZd Zd
Z
dZdZdZdZdZd'Zd(Zd)Zd*ZdZdZdZdZdZd
ZdZd
ZdZd
Z dj!d
�Z"dZ#dZ$dZ%dZ&dZ'dd� Z(dd� Z)dd� Z*dd� Z+dd� Z,dd� Z-d+dd�Z.dd� Z/dd � Z0d!d"� Z1d#d$� Z2d,d%d&�Z3dS )-a� usb.util - Utility functions.
This module exports:
endpoint_address - return the endpoint absolute address.
endpoint_direction - return the endpoint transfer direction.
endpoint_type - return the endpoint type
ctrl_direction - return the direction of a control transfer
build_request_type - build a bmRequestType field of a control transfer.
find_descriptor - find an inner descriptor.
claim_interface - explicitly claim an interface.
release_interface - explicitly release an interface.
dispose_resources - release internal resources allocated by the object.
get_langids - retrieve the list of supported string languages from the device.
get_string - retrieve a string descriptor from the device.
zWander Lairson Costa� N)�
hexversion� � � � � � � � zutf-8c C s | t @ S )z�Return the endpoint absolute address.
The address parameter is the bEndpointAddress field
of the endpoint descriptor.
)�_ENDPOINT_ADDR_MASK)�address� r
�/usr/lib/python3.6/util.py�endpoint_addresse s r c C s | t @ S )z�Return the endpoint direction.
The address parameter is the bEndpointAddress field
of the endpoint descriptor.
The possible return values are ENDPOINT_OUT or ENDPOINT_IN.
)�_ENDPOINT_DIR_MASK)r r
r
r �endpoint_directionm s r c C s | t @ S )a Return the transfer type of the endpoint.
The bmAttributes parameter is the bmAttributes field
of the endpoint descriptor.
The possible return values are: ENDPOINT_TYPE_CTRL,
ENDPOINT_TYPE_ISO, ENDPOINT_TYPE_BULK or ENDPOINT_TYPE_INTR.
)�_ENDPOINT_TRANSFER_TYPE_MASK)ZbmAttributesr
r
r �
endpoint_typev s r c C s | t @ S )z�Return the direction of a control request.
The bmRequestType parameter is the value of the
bmRequestType field of a control transfer.
The possible return values are CTRL_OUT or CTRL_IN.
)�_CTRL_DIR_MASK)Z
bmRequestTyper
r
r �ctrl_direction� s r c C s ||B | B S )a� Build a bmRequestType field for control requests.
These is a conventional function to build a bmRequestType
for a control request.
The direction parameter can be CTRL_OUT or CTRL_IN.
The type parameter can be CTRL_TYPE_STANDARD, CTRL_TYPE_CLASS,
CTRL_TYPE_VENDOR or CTRL_TYPE_RESERVED values.
The recipient can be CTRL_RECIPIENT_DEVICE, CTRL_RECIPIENT_INTERFACE,
CTRL_RECIPIENT_ENDPOINT or CTRL_RECIPIENT_OTHER.
Return the bmRequestType value.
r
)� direction�typeZ recipientr
r
r �build_request_type� s r c C s t j dt| �S )a< Create a buffer to be passed to a read function.
A read function may receive an out buffer so the data
is read inplace and the object can be reused, avoiding
the overhead of creating a new object at each new read
call. This function creates a compatible sequence buffer
of the given length.
�B)�array�_dummy_s)Zlengthr
r
r �
create_buffer� s r Fc sF � �fdd�}|r|f |�S yt j|f |��S tk
r@ dS X dS )a� Find an inner descriptor.
find_descriptor works in the same way as the core.find() function does,
but it acts on general descriptor objects. For example, suppose you
have a Device object called dev and want a Configuration of this
object with its bConfigurationValue equals to 1, the code would
be like so:
>>> cfg = util.find_descriptor(dev, bConfigurationValue=1)
You can use any field of the Descriptor as a match criteria, and you
can supply a customized match just like core.find() does. The
find_descriptor function also accepts the find_all parameter to get
an iterator instead of just one descriptor.
c ; sH xB�D ]:� � fdd�| j � D �}tj|�r�d ks:�� �r� V qW d S )Nc 3 s | ]\}}|t � |�kV qd S )N)�getattr)�.0�key�val)�dr
r � <genexpr>� s z5find_descriptor.<locals>.desc_iter.<locals>.<genexpr>)�items�_interopZ_all)�kwargsZtests)�custom_match�desc)r! r � desc_iter� s
z"find_descriptor.<locals>.desc_iterN)r$ Z_next�
StopIteration)r'