diff options
author | Justus Winter <[email protected]> | 2016-08-05 12:03:15 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-08-05 12:05:49 +0000 |
commit | 2a613e87156b23c4aa6aa5ce38505cb285de6a18 (patch) | |
tree | 2771ed69bf7299d1b1c9d89dca30b2e4119ac69a /lang/python/examples/testCMSgetkey.py | |
parent | core: Extend gpgme_subkey_t to carry the keygrip. (diff) | |
download | gpgme-2a613e87156b23c4aa6aa5ce38505cb285de6a18.tar.gz gpgme-2a613e87156b23c4aa6aa5ce38505cb285de6a18.zip |
python: Clean up and modernize examples.
* lang/python/examples/Examples.rst: Delete file.
* lang/python/examples/t-edit.py: Likewise. This is actually a test
case and has been moved to 'tests'.
* lang/python/examples/assuan.py: New file.
* lang/python/examples/decryption-filter.py: Likewise.
* lang/python/examples/delkey.py: Modernize.
* lang/python/examples/encrypt-to-all.py: Likewise.
* lang/python/examples/exportimport.py: Likewise.
* lang/python/examples/genkey.py: Likewise.
* lang/python/examples/inter-edit.py: Likewise.
* lang/python/examples/sign.py: Likewise.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/testCMSgetkey.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/examples/testCMSgetkey.py')
-rw-r--r-- | lang/python/examples/testCMSgetkey.py | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/lang/python/examples/testCMSgetkey.py b/lang/python/examples/testCMSgetkey.py index 7c953012..7c642e68 100644 --- a/lang/python/examples/testCMSgetkey.py +++ b/lang/python/examples/testCMSgetkey.py @@ -1,47 +1,32 @@ #!/usr/bin/env python3 -# initial 20080124 [email protected] -# 20080124-2: removed some superflous imports -# 20080703: adapted for pyme-0.8.0 -# This script is Free Software under GNU GPL v>=2. # -# No modification made for python3 port, Bernhard can field this one -# if it is still required. -- Ben McGinnes +# Copyright (C) 2016 g10 Code GmbH +# Copyright (C) 2008 Bernhard Reiter <[email protected]> # -"""A test applicaton for gpg_get_key() protocol.CMS. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <http://www.gnu.org/licenses/>. -Tested on Debian Etch with - pyme 0.8.0 (manually compiled) - libgpgme11 1.1.6-0kk2 - gpgsm 2.0.9-0kk2 -""" +"""A test applicaton for the CMS protocol.""" import sys -from pyme import core -from pyme.constants import protocol +import pyme -def printgetkeyresults(keyfpr): - """Run gpgme_get_key().""" +if len(sys.argv) != 2: + sys.exit("fingerprint or unique key ID for gpgme_get_key()") - # gpgme_check_version() necessary for initialisation according to - # gogme 1.1.6 and this is not done automatically in pyme-0.7.0 - print("gpgme version:", core.check_version(None)) - c = core.Context() - c.set_protocol(protocol.CMS) - - key = c.get_key(keyfpr, False) +with pyme.Context(protocol=pyme.constants.PROTOCOL_CMS) as c: + key = c.get_key(sys.argv[1], False) print("got key: ", key.subkeys[0].fpr) - for uid in key.uids: print(uid.uid) - -def main(): - if len(sys.argv) < 2: - print("fingerprint or unique key ID for gpgme_get_key()") - sys.exit(1) - - printgetkeyresults(sys.argv[1]) - - -if __name__ == "__main__": - main() |