gpgme/lang/python/examples/howto/advanced/cython/keycount.pyx
Ben McGinnes 362caaf02f docs: python bindings
* Updated the Cython example code slightly, along with the
  corresponding explanation.
2018-09-18 08:32:30 +10:00

27 lines
498 B
Cython
Executable File

from __future__ import absolute_import
import cython
import gpg
c = gpg.Context()
seckeys = c.keylist(pattern=None, secret=True)
pubkeys = c.keylist(pattern=None, secret=False)
seclist = list(seckeys)
secnum = len(seclist)
publist = list(pubkeys)
pubnum = len(publist)
if cython.compiled is True:
cc = "Powered by Cython compiled C code."
else:
cc = "Powered by Python."
print("""
Number of secret keys: {0}
Number of public keys: {1}
{2}
""".format(secnum, pubnum, cc))