MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / _sort_alias

Method _sort_alias

pgpy/pgp.py:2720–2737  ·  view source on GitHub ↗
(self, alias)

Source from the content-addressed store, hash-verified

2718 return [self._keys[m[alias]] for m in self._aliases if alias in m]
2719
2720 def _sort_alias(self, alias):
2721 # remove alias from all levels of _aliases, and sort by created time and key half
2722 # so the order of _aliases from left to right:
2723 # - newer keys come before older ones
2724 # - private keys come before public ones
2725 #
2726 # this list is sorted in the opposite direction from that, because they will be placed into self._aliases
2727 # from right to left.
2728 pkids = sorted(list(set().union(m.pop(alias) for m in self._aliases if alias in m)),
2729 key=lambda pkid: (self._keys[pkid].created, self._keys[pkid].is_public))
2730
2731 # drop the now-sorted aliases into place
2732 for depth, pkid in enumerate(pkids):
2733 self._aliases[depth][alias] = pkid
2734
2735 # finally, remove any empty dicts left over
2736 while {} in self._aliases: # pragma: no cover
2737 self._aliases.remove({})
2738
2739 def _add_alias(self, alias, pkid):
2740 # brand new alias never seen before!

Callers 2

_add_aliasMethod · 0.95
unloadMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected