Takes a comma-separated string of key ids or fingerprints and returns a list of key ids
423016
def match_keys(inp, p=False):
    """"""
    _keys = []
    ssh_keys = DO.get_ssh_keys()
    for k in inp.split(","):
        done = False
        if k.isdigit():
            for _ in [s for s in ssh_keys if s["id"] == int(k)]:
                done = True
                _keys.append(_["fingerprint"])
        else:
            for _ in [s for s in ssh_keys if s["fingerprint"] == k]:
                done = True
                _keys.append(_["fingerprint"])
        if p and not done:
            print("Could not find a match for '{}', skipping".format(k), file=sys.stderr)
    return _keys
758554
public static List<String> keys(String prefix, Map<String, String> data) {
        logger.debug("get keys for {}", prefix);
        // matches: 'prefix.xxx...' | 'prefix."xxx.t"...'
        Pattern keyPattern = Pattern.compile("^" + Pattern.quote(prefix) + "\\.(\"[^\"]+\"|[^\\.]+).*$");
        return data.keySet().stream()
                .map(key -> {
                    Matcher m = keyPattern.matcher(key);
                    return m.matches() ? m.group(1)
                            : null;
                }).filter(k -> k != null)
                .distinct()
                .collect(Collectors.toList());
    }
860125
def _stringifyKeys(d):
    
    return dict((k.encode('ascii'), v)  for (k, v) in d.iteritems())
1033801
def keys_info(gandi, fqdn, key):
    """"""
    key_info = gandi.dns.keys_info(fqdn, key)
    output_keys = ['uuid', 'algorithm', 'algorithm_name', 'ds', 'fingerprint',
                   'public_key', 'flags', 'tag', 'status']
    output_generic(gandi, key_info, output_keys, justify=15)
    return key_info
1157383
def get_repo_keys():
    '''
    
    '''
    ret = dict()
    repo_keys = list()

    # The double usage of '--with-fingerprint' is necessary in order to
    # retrieve the fingerprint of the subkey.
    cmd = ['apt-key', 'adv', '--batch', '--list-public-keys', '--with-fingerprint',
           '--with-fingerprint', '--with-colons', '--fixed-list-mode']

    cmd_ret = _call_apt(cmd, scope=False)

    if cmd_ret['retcode'] != 0:
        log.error(cmd_ret['stderr'])
        return ret

    lines = [line for line in cmd_ret['stdout'].splitlines() if line.strip()]

    # Reference for the meaning of each item in the colon-separated
    # record can be found here: https://goo.gl/KIZbvp
    for line in lines:
        items = [_convert_if_int(item.strip()) if item.strip() else None for item in line.split(':')]
        key_props = dict()

        if len(items) < 2:
            log.debug('Skipping line: %s', line)
            continue

        if items[0] in ('pub', 'sub'):
            key_props.update({
                'algorithm': items[3],
                'bits': items[2],
                'capability': items[11],
                'date_creation': items[5],
                'date_expiration': items[6],
                'keyid': items[4],
                'validity': items[1]
            })

            if items[0] == 'pub':
                repo_keys.append(key_props)
            else:
                repo_keys[-1]['subkey'] = key_props
        elif items[0] == 'fpr':
            if repo_keys[-1].get('subkey', False):
                repo_keys[-1]['subkey'].update({'fingerprint': items[9]})
            else:
                repo_keys[-1].update({'fingerprint': items[9]})
        elif items[0] == 'uid':
            repo_keys[-1].update({
                'uid': items[9],
                'uid_hash': items[7]
            })

    for repo_key in repo_keys:
        ret[repo_key['keyid']] = repo_key
    return ret
383789
function getAllFingerprints(dir) {
	var ids = getAnimals();
	var fgps = ids.map(function (id) {
		return getFingerprintsForAnimal(path.join(dir, id));
	}).filter(function (fgp) { return fgp; });
	return fgps;
}
495112
def keylist(self):
        """"""
        items = self.enumerations.items()
        items.sort(lambda a, b: self.cmp(a[1], b[1]))

        # last item has highest value
        rslt = [None] * (items[-1][1] + 1)

        # map the values
        for key, value in items:
            rslt[value] = key

        # return the result
        return rslt
135287
def _list_keys(self):
        
        req = self.request(self.uri + '/keys')
        keys = req.get().json()
        if keys:
            self._keys = {}
            for key in keys:
                self._keys[key['id']] = Key(key, self)
        else:
            self._keys = {}
200510
def addresses_for_key(gpg, key):
    
    return [address.split("<")[-1].strip(">")
            for address in gpg.list_keys().key_map[key['fingerprint']]["uids"]
            if address]
144316
def _list_keys(user=None, gnupghome=None, secret=False):
    '''
    
    '''
    gpg = _create_gpg(user, gnupghome)
    _keys = gpg.list_keys(secret)
    return _keys
689393
def keys(self):
        " "
        if self.ndims == 1:
            return [k[0] for k in self.data.keys()]
        else:
            return list(self.data.keys())
1089036
def _batch_key(self, query):
    '''
    
    '''
    return ''.join( ['%s%s'%(k,v) for k,v in sorted(query.items())] )
1363021
def _pairs(keys, *, start=1, sep=' AND '):
    '''
    
    '''
    return sep.join('{}=${}'.format(k, i) for i, k in enumerate(keys, start))
1198901
def _data_keys(self):
        
        return [name for name, child in iteritems(self._children) if not isinstance(child, GroupNode)]
778630
def fingerprint_from_keybase(fingerprint, kb_obj):
    """"""
    if 'public_keys' in kb_obj and \
       'pgp_public_keys' in kb_obj['public_keys']:
        for key in kb_obj['public_keys']['pgp_public_keys']:
            keyprint = fingerprint_from_var(key).lower()
            fingerprint = fingerprint.lower()
            if fingerprint == keyprint or \
               keyprint.startswith(fingerprint) or \
               keyprint.endswith(fingerprint):
                return {
                    'fingerprint': keyprint,
                    'bundle': key
                }

    return None
651642
function parseKey (inp) {
    var res = parseString(inp);
    if (res) return res;
  
    var match = inp.takeAPeek(JS_IDENT);
    if (match) return match[0]
  }
14846
def get_key_codes(keys):
    
    keys = keys.strip().upper().split('+')
    codes = list()
    for key in keys:
        code = ks_settings.KEY_CODES.get(key.strip())
        if code:
            codes.append(code)
    return codes