Get a device from a device dictionary.

    :param name: name of the device
    :param device_dict: device dictionary
    :rtype: Device
162128
def get_device(name, device_dict, loader, resource_dict):
    
    device = Device(name, device_dict.get('delimiter', ';').encode('utf-8'))

    device_dict = get_bases(device_dict, loader)

    err = device_dict.get('error', {})
    device.add_error_handler(err)

    for itype, eom_dict in device_dict.get('eom', {}).items():
        device.add_eom(itype, *_get_pair(eom_dict))

    update_component(name, device, device_dict)

    for ch_name, ch_dict in device_dict.get('channels', {}).items():
        device.add_channels(ch_name, get_channel(device, ch_name, ch_dict,
                                                 loader, resource_dict))

    return device
1047752
def get_device_model(self, cat, sub_cat, key=''):
        """"""
        if cat + ':' + sub_cat in self.device_models:
            return self.device_models[cat + ':' + sub_cat]
        else:
            for i_key, i_val in self.device_models.items():
                if 'key' in i_val:
                    if i_val['key'] == key:
                        return i_val
            return False
1233375
def get_device(self, device_id):
        
        api = self._get_api(device_directory.DefaultApi)
        return Device(api.device_retrieve(device_id))
648536
def get_xid_device(device_number):
    
    scanner = XidScanner()
    com = scanner.device_at_index(device_number)
    com.open()
    return XidDevice(com)
325148
def _get_device_group(self, device):
        '''
        '''

        return device.tm.cm.device_groups.device_group.load(
            name=self.name, partition=self.partition
        )
497118
def device(self):
		

		hdevice = self._libinput.libinput_event_get_device(self._hevent)
		return Device(hdevice, self._libinput)
123589
def get_devices(device_type: DeviceType) -> Iterator[str]:
    
    for device in BASE_PATH.iterdir():
        with open(str(Path(device, 'type'))) as type_file:
            if type_file.readline().strip() == device_type.value:
                yield device.name
1260681
def get_device_names_to_objects(devices):
    '''
    '''

    name_to_object = {}
    for device in devices:
        device_name = get_device_info(device).name
        name_to_object[device_name] = device
    return name_to_object
323231
def variable_device(device, name):
  """"""
  if callable(device):
    var_name = tf.get_variable_scope().name + '/' + name
    var_def = tf.NodeDef(name=var_name, op='Variable')
    device = device(var_def)
  if device is None:
    device = ''
  return device
1090578
def port_id_from_name(port_name, device_id, nodes):
        
        port_id = None
        for node in nodes:
            if device_id == node['id']:
                for port in node['ports']:
                    if port_name == port['name']:
                        port_id = port['id']
                        break
                break
        return port_id
1356636
def evdev_device(self):
        
        devices = [evdev.InputDevice(fn) for fn in evdev.list_devices()]

        for device in devices:
            if device.name == self.evdev_device_name:
                return device

        raise Exception("%s: could not find evdev device '%s'" % (self, self.evdev_device_name))
211411
def async_get_device(self, uid, fields='*'):
        """"""
        return (yield from self._get('/pods/{}'.format(uid),
                                     fields=fields))
419691
def get_ports_by_name(device_name):
    ''''''
    filtered_devices = filter(
        lambda device: device_name in device[1],
        list_ports.comports()
    )
    device_ports = [device[0] for device in filtered_devices]
    return device_ports
906497
def set_device(self, device_name):
    
    device_name = unify_device_name(device_name)
    self.device_name = device_name
    for layer in self.layers:
      layer.device_name = device_name
5843
def read_dev_prop(self, device_name):
        
        with open("{}.bin".format(device_name), "rb") as file:
            return pickle.load(file)["device"]
432231
def get_device_element(self, ain):
        """"""
        elements = self.get_device_elements()
        for element in elements:
            if element.getAttribute('identifier') == ain:
                return element
        return None
751630
def __read_device(self):
        """"""
        state = XinputState()
        res = self.manager.xinput.XInputGetState(
            self.__device_number, ctypes.byref(state))
        if res == XINPUT_ERROR_SUCCESS:
            return state
        if res != XINPUT_ERROR_DEVICE_NOT_CONNECTED:
            raise RuntimeError(
                "Unknown error %d attempting to get state of device %d" % (
                    res, self.__device_number))
        # else (device is not connected)
        return None