File: //lib/python3.6/site-packages/usb/__pycache__/core.cpython-36.pyc
3
�~�Vp� � @ s< d Z dZddddddgZdd ljZdd lZdd lZdd ljZdd l j
Z
dd ljZ
dd lZdd lZdd lZdd lZejd
�ZdZdd
� Zd%dd�Zd&dd�ZG dd� de�Zdd� ZG dd� de�ZG dd� de�ZG dd� de�Z G dd� de�Z!G dd� de�Z"G d d� de�Z#G d!d� de
j$�Z%d'd#d�Z&d(d$d�Z'd S ))av usb.core - Core USB features.
This module exports:
Device - a class representing a USB device.
Configuration - a class representing a configuration descriptor.
Interface - a class representing an interface descriptor.
Endpoint - a class representing an endpoint descriptor.
find() - a function to find USB devices.
show_devices() - a function to show the devices present.
zWander Lairson Costa�Device�
Configuration� Interface�Endpoint�find�show_devices� Nzusb.corei� c C s$ x|D ]}t ||t| |�� qW d S )N)�setattr�getattr)�input�outputZfields�f� r
�/usr/lib/python3.6/core.py� _set_attr= s
r � �Error Accessing Stringc
C sL |dkr|}n:y(|dkr&t j| |�}nt j| ||�}W n |}Y nX |S )z= try to get a string, but return a string no matter what
r N)�util�
get_string)�dev�indexZlangidZdefault_str_i0Zdefault_access_error�stringr
r
r �_try_get_stringA s
r c C s* y| | }W n t k
r$ |}Y nX |S )zS try to get a string from the lookup table, return "" instead of key
error
)�KeyError)�table�value�defaultr r
r
r �_try_lookupQ s
r c @ s e Zd ZdZdd� ZdS )�_DescriptorInfozc this class is used so that when a descriptor is shown on the
terminal it is propely formatted c C s | S )Nr
)�selfr
r
r �__repr__^ s z_DescriptorInfo.__repr__N)�__name__�
__module__�__qualname__�__doc__r r
r
r
r r [ s r c s t j� �� fdd��}|S )Nc
s, z| j j� � | f|�|�S | j j� X d S )N)�lock�acquire�release)r �args�kwargs)r r
r �wrapperb s
zsynchronized.<locals>.wrapper)� functools�wraps)r r) r
)r r �synchronizeda s r, c @ s� e Zd Zdd� Zedd� �Zedd� �Zedd� �Zed d
� �Zedd� �Z ed
d� �Z
edd� �Zedd� �Zedd� �Z
edd� �Zeddd��ZdS )�_ResourceManagerc C s6 || _ d | _|| _d | _tj� | _i | _tj � | _
d S )N)�backend�_active_cfg_indexr �handle�_interopZ_set�
_claimed_intf�_ep_info� threading�RLockr$ )r r r. r
r
r �__init__l s
z_ResourceManager.__init__c C s | j d kr| jj| j�| _ | j S )N)r0 r. Zopen_devicer )r r
r
r �managed_openu s
z_ResourceManager.managed_openc C s"