Common scanning skeleton.

        :param key: optional function used to identify what 'match' is applied to
968881
def _common_scan(self, values_function, cursor='0', match=None, count=10, key=None):
        
        if count is None:
            count = 10
        cursor = int(cursor)
        count = int(count)
        if not count:
            raise ValueError('if specified, count must be > 0: %s' % count)

        values = values_function()
        if cursor + count >= len(values):
            # we reached the end, back to zero
            result_cursor = 0
        else:
            result_cursor = cursor + count

        values = values[cursor:cursor+count]

        if match is not None:
            regex = re.compile(b'^' + re.escape(self._encode(match)).replace(b'\\*', b'.*') + b'$')
            if not key:
                key = lambda v: v
            values = [v for v in values if regex.match(key(v))]

        return [result_cursor, values]
1354605
def Match(self, registry_key):
    
    value_names = frozenset([
        registry_value.name for registry_value in registry_key.GetValues()])

    return self._value_names.issubset(value_names)
279936
def _has_valid_tuple(self, key):
        
        for i, k in enumerate(key):
            if i >= self.obj.ndim:
                raise IndexingError('Too many indexers')
            try:
                self._validate_key(k, i)
            except ValueError:
                raise ValueError("Location based indexing can only have "
                                 "[{types}] types"
                                 .format(types=self._valid_types))
733614
def scan(cls, result_key, func):
        

        if result_key in cls.scanner_keys:
            raise ValueError("'%s' is already a registered scanner key" % result_key)

        def scanner(self):
            result = func(self)
            setattr(self, result_key, result)

        cls.scanners.append(scanner)
        cls.scanner_keys.add(result_key)
945251
def get_match_value(rexobj, key, index=0):
    '''
    
    '''
    if rexobj is None:
        return None

    if rexobj.res_count == 0:
        return None

    try:
        return rexobj.matches[index].named_groups[key]
    except IndexError:
        return None
    except KeyError:
        return None
1278166
def _check_key(self, key):
        
        if not len(key) == 2:
            raise TypeError('invalid key: %r' % key)
        elif key[1] not in TYPES:
            raise TypeError('invalid datatype: %s' % key[1])
366303
def getone(self, key):
        
        v = self.getall(key)
        if not v:
            raise KeyError('Key not found: %r' % key)
        if len(v) > 1:
            raise KeyError('Multiple values match %r: %r' % (key, v))
        return v[0]
457211
def contains(self, key, counter_id):
        
        with self._lock:
            return counter_id in self._metadata[key]
488194
def identifier(key)
      key &&= key.to_sym
      return unless Rudy::ID_MAP.has_key?(key)
      Rudy::ID_MAP[key]
    end
567411
def scan(self, cursor=0, match=None, count=None):
        
        pieces = [cursor]
        if match is not None:
            pieces.extend([Token.get_token('MATCH'), match])
        if count is not None:
            pieces.extend([Token.get_token('COUNT'), count])
        return self.execute_command('SCAN', *pieces)
237908
def search(key)
      base = @base
      chck = @chck
      node = @base[0]
      kin = KeyStream.new(key)
    
      while true
        code = kin.read
        idx = node + code
        node = base[idx]
      
        if(chck[idx] == code)
          if(node >= 0)
            next
          elsif(kin.eos? or key_exists?(kin, node))
            return Node::Base.ids(node)
          end
          return -1
        end
      end
    end
1253799
def _valid_key(self, key):
        
        if not isinstance(key, str):
            return False
        elif hasattr({}, key):
            return False
        elif key in self._special_names:
            return False
        else:
            return self._valid_key_pattern.match(key)
638210
def key_to_scan_codes(key, error_if_missing=True):
    
    if _is_number(key):
        return (key,)
    elif _is_list(key):
        return sum((key_to_scan_codes(i) for i in key), ())
    elif not _is_str(key):
        raise ValueError('Unexpected key type ' + str(type(key)) + ', value (' + repr(key) + ')')

    normalized = normalize_name(key)
    if normalized in sided_modifiers:
        left_scan_codes = key_to_scan_codes('left ' + normalized, False)
        right_scan_codes = key_to_scan_codes('right ' + normalized, False)
        return left_scan_codes + tuple(c for c in right_scan_codes if c not in left_scan_codes)

    try:
        # Put items in ordered dict to remove duplicates.
        t = tuple(_collections.OrderedDict((scan_code, True) for scan_code, modifier in _os_keyboard.map_name(normalized)))
        e = None
    except (KeyError, ValueError) as exception:
        t = ()
        e = exception

    if not t and error_if_missing:
        raise ValueError('Key {} is not mapped to any known key.'.format(repr(key)), e)
    else:
        return t
533617
def process_regex(self, key):
        
        return re.compile(self.output_dict[key]) if \
            key in self.output_dict else None
863977
def detect_member(row, key):
    '''  '''
    (target, tkey, tvalue) = dict_crawl(row, key)
    if target:
        return True
    return False
1015585
private boolean matchesExpectedKey(int position, Page page)
    {
        for (int i = 0; i < indexKeyTypes.size(); i++) {
            if (!indexKeyTypes.get(i).equalTo(page.getBlock(i), position, indexKeyTuple.getBlock(i), 0)) {
                return false;
            }
        }
        return true;
    }
267429
def sscan(self, key, cursor=0, match=None, count=None):
        """"""
        tokens = [key, cursor]
        match is not None and tokens.extend([b'MATCH', match])
        count is not None and tokens.extend([b'COUNT', count])
        fut = self.execute(b'SSCAN', *tokens)
        return wait_convert(fut, lambda obj: (int(obj[0]), obj[1]))