d4c08840d3762b76c50f535a15922b5a36255ee5
[platform/upstream/gpgme.git] / lang / python / examples / testCMSgetkey.py
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2016 g10 Code GmbH
4 # Copyright (C) 2008 Bernhard Reiter <bernhard@intevation.de>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 """A test applicaton for the CMS protocol."""
20
21 from __future__ import absolute_import, print_function, unicode_literals
22 del absolute_import, print_function, unicode_literals
23
24 import sys
25 import gpg
26
27 if len(sys.argv) != 2:
28     sys.exit("fingerprint or unique key ID for gpgme_get_key()")
29
30 with gpg.Context(protocol=gpg.constants.protocol.CMS) as c:
31     key = c.get_key(sys.argv[1])
32
33     print("got key: ", key.subkeys[0].fpr)
34     for uid in key.uids:
35         print(uid.uid)