Extract the key from two host entries and compare them.

    :param key_1: Host key
    :type key_1: str
    :param key_2: Host key
    :type key_2: str
552153
def is_same_key(key_1, key_2):
    
    # The key format get will be like '|1|2rUumCavEXWVaVyB5uMl6m85pZo=|Cp'
    # 'EL6l7VTY37T/fg/ihhNb/GPgs= ssh-rsa AAAAB', we only need to compare
    # the part start with 'ssh-rsa' followed with '= ', because the hash
    # value in the beginning will change each time.
    k_1 = key_1.split('= ')[1]
    k_2 = key_2.split('= ')[1]
    return k_1 == k_2
1251477
def get(self, key):
        
        if not self.servers:
            return self.miss

        key = self._qualified_key(key)
        hashed_key = self.key_hasher(key)
        entry = self.client.get(hashed_key)

        if isinstance(entry, tuple) and len(entry) == 2:
            key_, result = entry
            if key_ == key:
                self.logger("HIT: %s", key)
                return result

        self.logger("MISS: %s", key)
        return self.miss
1047137
def _lookup(key):
    
    if key not in _CACHE:
        return None
    if _CACHE_COUNTER[key] >= len(_CACHE[key][1:]):
        if _CACHE[key][0] == "empty":
            return ""
        elif _CACHE[key][0] == "repeat" and _CACHE[key][1:]:
            return _CACHE[key][-1]
        elif _CACHE[key][0] == "repeat":
            return ""
        else:
            _CACHE_COUNTER[key] = 1
    else:
        _CACHE_COUNTER[key] += 1
    if _CACHE[key]:
        return _CACHE[key][_CACHE_COUNTER[key]]
    else:
        return ""
825731
def swap_priority(self, key1, key2):
        
        heap = self._heap
        position = self._position
        if key1 not in self or key2 not in self:
            raise KeyError
        pos1, pos2 = position[key1], position[key2]
        heap[pos1].key, heap[pos2].key = key2, key1
        position[key1], position[key2] = pos2, pos1
976287
def assert_keys_are_subset(dict1, dict2):
    
    keys1 = set(dict1.keys())
    keys2 = set(dict2.keys())
    unknown_keys = keys2.difference(keys1)
    assert len(unknown_keys) == 0, 'unknown_keys=%r' % (unknown_keys,)
686119
def extract(dictionary, keys):
    
    return dict((k, dictionary[k]) for k in keys if k in dictionary)
90070
function (key1, key2) {
    var self = this;
    if (key1.length !== self._sortSpecParts.length ||
        key2.length !== self._sortSpecParts.length) {
      throw Error("Key has wrong length");
    }

    return self._keyComparator(key1, key2);
  }
834694
def _compare_match(dict1, dict2):
    '''
    
    '''
    for karg, warg in six.iteritems(dict1):
        if karg in dict2 and dict2[karg] != warg:
            return False
    return True
625206
public static function keyMatch2($key1, $key2)
    {
        $key2 = str_replace(['/*'], ['/.*'], $key2);

        $pattern = '/(.*):[^\/]+(.*)/';
        for (; ;) {
            if (false === strpos($key2, '/:')) {
                break;
            }
            $key2 = preg_replace_callback(
                $pattern,
                function ($m) {
                    return $m[1].'[^\/]+'.$m[2];
                },
                $key2
            );
            $key2 = '^'.$key2.'$';
        }

        return self::regexMatch($key1, $key2);
    }
553979
def get_key(key_name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        key = conn.get_key_pair(key_name)
        log.debug("the key to return is : %s", key)
        if key is None:
            return False
        return key.name, key.fingerprint
    except boto.exception.BotoServerError as e:
        log.debug(e)
        return False
226473
def get_from_dicts(dict1, key, default_value, dict2, extra=''):
    

    value=default_value

    if key not in dict1:
       if dict2!=None:
          value=dict2.get(extra+key, default_value)
    else:
       value=dict1[key]
       del(dict1[key])

       if dict2!=None:
          dict2[extra+key]=value

    return value
754564
def get_other_keys(self, key, including_current=False):
        
        other_keys = []
        if key in self:
            other_keys.extend(self.__dict__[str(type(key))][key])
            if not including_current:
                other_keys.remove(key)
        return other_keys
1232422
def copy_keys(source, destination, keys=None):
    
    if keys is None:
        keys = destination.keys()
    for k in set(source) & set(keys):
        destination[k] = source[k]
    return destination
138310
def _revs_equal(rev1, rev2, rev_type):
    '''
    
    '''
    if (rev1 is None and rev2 is not None) \
            or (rev2 is None and rev1 is not None):
        return False
    elif rev1 is rev2 is None:
        return True
    elif rev_type == 'sha1':
        return rev1.startswith(rev2)
    else:
        return rev1 == rev2
154505
def _hostname_matches(self, hostname, entry):
        
        for h in entry.hostnames:
            if (
                h == hostname
                or h.startswith("|1|")
                and not hostname.startswith("|1|")
                and constant_time_bytes_eq(self.hash_host(hostname, h), h)
            ):
                return True
        return False
1130483
def chained_get(self, *keys):
        
        existing = self
        for i in range(0, len(keys)):
            if keys[i] in existing:
                existing = existing[keys[i]]
            else:
                return None
        return existing
190306
def _get(self, word1, word2):
        
        key = self._WSEP.join([self._sanitize(word1), self._sanitize(word2)])
        key = key.lower()
        if key not in self._db:
            return

        return sample(self._db[key], 1)[0]