Check whether the current channel is correct. If not try to determine it
    using fuzzywuzzy
18305
async def async_determine_channel(channel):
    '''
    
    '''
    from fuzzywuzzy import process
    channel_data = await async_get_channels()
    if not channel_data:
        _LOGGER.error('No channel data. Cannot determine requested channel.')
        return
    channels = [c for c in channel_data.get('data', {}).keys()]
    if channel in channels:
        return channel
    else:
        res = process.extractOne(channel, channels)[0]
        _LOGGER.debug('No direct match found for %s. Resort to guesswork.'
                      'Guessed %s', channel, res)
        return res
1225182
def is_correct(self):
        
        state = True

        # Internal checks before executing inherited function...
        if not hasattr(self, 'check_command'):
            msg = "[checkmodulation::%s] do not have any check_command defined" % (
                self.get_name()
            )
            self.add_error(msg)
            state = False
        else:
            if self.check_command is None:
                msg = "[checkmodulation::%s] a check_command is missing" % (self.get_name())
                self.add_error(msg)
                state = False
            if self.check_command and not self.check_command.is_valid():
                msg = "[checkmodulation::%s] a check_command is invalid" % (self.get_name())
                self.add_error(msg)
                state = False

        # Ok just put None as check_period, means 24x7
        if not hasattr(self, 'check_period'):
            self.check_period = None

        return super(CheckModulation, self).is_correct() and state
1122929
def channels(self):
        """"""
        if hasattr(self.mgfile.info, 'channels'):
            return self.mgfile.info.channels
        return 0
414125
def prepare(self):
        
        try:
            assert(type(self.sender) is Channel)
            assert(type(self.receiver) is Channel)
            return True
        except:
            return False
833795
def _validate_channel_definition(self, jp2h, colr):
        """"""
        cdef_lst = [j for (j, box) in enumerate(jp2h.box)
                    if box.box_id == 'cdef']
        if len(cdef_lst) > 1:
            msg = ("Only one channel definition box is allowed in the "
                   "JP2 header.")
            raise IOError(msg)
        elif len(cdef_lst) == 1:
            cdef = jp2h.box[cdef_lst[0]]
            if colr.colorspace == core.SRGB:
                if any([chan + 1 not in cdef.association or
                        cdef.channel_type[chan] != 0 for chan in [0, 1, 2]]):
                    msg = ("All color channels must be defined in the "
                           "channel definition box.")
                    raise IOError(msg)
            elif colr.colorspace == core.GREYSCALE:
                if 0 not in cdef.channel_type:
                    msg = ("All color channels must be defined in the "
                           "channel definition box.")
                    raise IOError(msg)
1200595
async def async_get_current_program(channel, no_cache=False):
    '''
    
    '''
    chan = await async_determine_channel(channel)
    guide = await async_get_program_guide(chan, no_cache)
    if not guide:
        _LOGGER.warning('Could not retrieve TV program for %s', channel)
        return
    now = datetime.datetime.now()
    for prog in guide:
        start = prog.get('start_time')
        end = prog.get('end_time')
        if now > start and now < end:
            return prog
127514
def _unpickle_channel(raw):
    
    try:
        return pickle.loads(raw)
    except (ValueError, pickle.UnpicklingError, EOFError, TypeError,
            IndexError) as exc:
        # maybe not pickled
        if isinstance(raw, bytes):
            raw = raw.decode('utf-8')
        try:  # test if this is a valid channel name
            Channel.MATCH.match(raw)
        except ValueError:
            raise exc
        return raw
1138551
def _get_channel(self):
        
        channel = self._transport.open_session()
        channel.set_combine_stderr(True)
        channel.get_pty()
        return channel
702018
def _check_for_outdated_channel(
            self,
            participant1: Address,
            participant2: Address,
            block_identifier: BlockSpecification,
            channel_identifier: ChannelID,
    ) -> None:
        
        try:
            onchain_channel_details = self._detail_channel(
                participant1=participant1,
                participant2=participant2,
                block_identifier=block_identifier,
            )
        except RaidenRecoverableError:
            return

        onchain_channel_identifier = onchain_channel_details.channel_identifier

        if onchain_channel_identifier != channel_identifier:
            raise ChannelOutdatedError(
                'Current channel identifier is outdated. '
                f'current={channel_identifier}, '
                f'new={onchain_channel_identifier}',
            )
370383
def detect(self):
        """"""
        for theip in self.rips:
            LOG.debug("detected %s", str(theip))
            self.set_current_value(str(theip))
            return str(theip)
997077
def system_channel(self):
        
        channel_id = self._system_channel_id
        return channel_id and self._channels.get(channel_id)
523000
def on_welcome(self, c, e):
        
        self.backoff = 1  # Assume we had a good connection. Reset backoff.
        if self.nickserv:
            if Utilities.isNotEmpty(self.nickserv_pass):
                self.identify(c, e, self.nickserv_pass)
                time.sleep(3)  # Make sure Nickserv really sees us
            else:
                logger.error('If nickserv is enabled, you must supply'
                             ' a password')

        if self.nickserv is False and self.nickserv_pass is not None:
            logger.warn('It appears you provided a nickserv password but '
                        'did not enable nickserv authentication')

        for channel in self.my_channels:
            logger.debug('Attempting to join {0!s}'.format(channel))
            c.join(channel)
622897
def get_over_current(self, channel):
        '''
        '''
        try:
            bit = self._ch_map[channel]['GPIOOC']['bit']
        except KeyError:
            raise ValueError('get_over_current() not supported for channel %s' % channel)
        return not self._get_power_gpio_value(bit)
1074660
function (self, cmd, channel, cb) {
		if (typeof(cb) != "function") {
			cb = false;
		}

		if (typeof(channel) == "number") {
			channel = channel.toString();
		}

		if (typeof(channel) != "string" || !/[0-9]+-[0-9]+/.test(channel)) {
			self.log("Invalid channel");
			return cb && cb(new Error("Invalid channel"));
		}

		self.sendCommand("CG " + channel + " " + cmd + " 1", cb);
	}
746235
def hascurrent(self, allowempty=False):
        """"""
        for e in self.select(Current,None,False, False):
            if not allowempty and len(e) == 0: continue
            return True
        return False
76644
def check(self):
        '''  '''
        if self.lastrun + self.interval < time.time():
            return True
        else:
            return False
17984
def check_channels!(integration)
      integration.channels.map(&:network).map(&:name).each do |network|
        find_network!(network)
      end
    end