Get a channels from a channels dictionary.

    :param name: name of the device
    :param device_dict: device dictionary
    :rtype: Device
973501
def get_channel(device, ch_name, channel_dict, loader, resource_dict):
    
    channel_dict = get_bases(channel_dict, loader)

    r_ids = resource_dict.get('channel_ids', {}).get(ch_name, [])
    ids = r_ids if r_ids else channel_dict.get('ids', {})

    can_select = False if channel_dict.get('can_select') == 'False' else True
    channels = Channels(device, ids, can_select)

    update_component(ch_name, channels, channel_dict)

    return channels
1307254
def device_filter(self):
        
        if isinstance(self._device_filter, str):
            return self._decode_query(self._device_filter)
        return self._device_filter
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
1011493
def subscribe(self, channel_name):
        
        data = {'channel': channel_name}

        if channel_name.startswith('presence-'):
            data['auth'] = self._generate_presence_key(
                self.connection.socket_id,
                self.key,
                channel_name,
                self.secret,
                self.user_data
            )
            data['channel_data'] = json.dumps(self.user_data)
        elif channel_name.startswith('private-'):
            data['auth'] = self._generate_private_key(
                self.connection.socket_id,
                self.key,
                channel_name,
                self.secret
            )

        self.connection.send_event('pusher:subscribe', data)

        self.channels[channel_name] = Channel(channel_name, self.connection)

        return self.channels[channel_name]
232716
def _get_device_grain(name, proxy=None):
    '''
    
    '''
    device = _retrieve_device_cache(proxy=proxy)
    return device.get(name.upper())
1169533
def devices():
    
    udids = [udid.strip() for udid in idevice('_id', '-l').splitlines() if udid.strip()]
    return {udid: idevice('name', '-u', udid).decode('utf-8').strip() for udid in udids}
1106257
def load_devices(self):
        
        self._devices = []
        if os.path.exists(self._devices_filename):
            log.debug(
                "loading devices from '{}'...".format(self._devices_filename)
            )
            with codecs.open(self._devices_filename, "rb", "utf-8") as f:
                self._devices = json.load(f)

        return self._devices
1308000
def _get_setup(self, result):
        """"""
        self.__devices = {}

        if ('setup' not in result.keys() or
                'devices' not in result['setup'].keys()):
            raise Exception(
                "Did not find device definition.")

        for device_data in result['setup']['devices']:
            device = Device(self, device_data)
            self.__devices[device.url] = device

        self.__location = result['setup']['location']
        self.__gateway = result['setup']['gateways']
207499
def _fetch_channels(self):
        """"""
        json = requests.get(self._channels_url).json()
        self._channels = {c['channel']['code']: c['channel']['name']
                          for c in json['channels']}
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
850564
def by_name(name):
    
    devices = discover(all_households=True)
    for device in (devices or []):
        if device.player_name == name:
            return device
    return None
1314913
def get_channel(self, name):
        
        name = quote(name, '')
        path = Client.urls['channels_by_name'] % name
        chan = self._call(path, 'GET')
        return chan
427473
def get_device_by_id(self, device_id):
        

        # Find the device for the vera device name we are interested in
        found_device = None
        for device in self.get_devices():
            if device.device_id == device_id:
              found_device = device
              # found the first (and should be only) one so we will finish
              break

        if found_device is None:
            logger.debug('Did not find device with {}'.format(device_id))

        return found_device
509274
def find_device_by_name(name):
    """"""
    if not name:
        return DEFAULT_DEV
    with DEV_LOCK:
        for dev in DEVS:
            if dev.name == name:
                return dev
    return None
913808
def get_tensor_device(self, tensor_name):
    
    tensor = self._name_to_tensor(tensor_name)
    if isinstance(tensor, tf.Tensor):
      return tensor.device
    else:  # mtf.Tensor
      return None
215847
async def get_devices(self, covers_only: bool = True) -> list:
        """"""
        from .device import MyQDevice

        _LOGGER.debug('Retrieving list of devices')
        devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
        # print(json.dumps(devices_resp, indent=4))

        device_list = []
        if devices_resp is None:
            return device_list

        for device in devices_resp['Devices']:
            if not covers_only or \
               device['MyQDeviceTypeName'] in SUPPORTED_DEVICE_TYPE_NAMES:

                self._devices.append({
                    'device_id': device['MyQDeviceId'],
                    'device_info': device
                })
                myq_device = MyQDevice(
                    self._devices[-1], self._brand, self)
                device_list.append(myq_device)

        # Store current device states.
        self._store_device_states(devices_resp.get('Devices', []))

        _LOGGER.debug('List of devices retrieved')
        return device_list
1224285
def get_device_status(self, t):
        ''''''
        data = {}
        for name, (func, _, _) in self.addons.iteritems():
            data[name] = func(t)
        return data