diff options
author | Justus Winter <[email protected]> | 2017-03-21 11:32:31 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2017-03-21 11:55:33 +0000 |
commit | f3e8d8a4518de2768692e0b392262d0da6d0fd84 (patch) | |
tree | 8aaea23c79f205d9c61a36525d14a32f57408601 /lang/python/gpg/core.py | |
parent | core: Extend gpgme_get_dirinfo to return the gpg-wks-client name. (diff) | |
download | gpgme-f3e8d8a4518de2768692e0b392262d0da6d0fd84.tar.gz gpgme-f3e8d8a4518de2768692e0b392262d0da6d0fd84.zip |
python: Wrap 'gpgme_op_keylist_from_data_start'.
* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): New keyword argument
'source'. If given, list keys from 'source'.
* lang/python/gpgme.i: Wrap the argument to
'gpgme_op_keylist_from_data_start'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/support.py (EphemeralContext): Do not throw an
error if no agent has been started in the context.
* lang/python/tests/t-keylist-from-data.py: New file.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/gpg/core.py')
-rw-r--r-- | lang/python/gpg/core.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lang/python/gpg/core.py b/lang/python/gpg/core.py index fe0ba81c..632f4ca5 100644 --- a/lang/python/gpg/core.py +++ b/lang/python/gpg/core.py @@ -484,13 +484,16 @@ class Context(GpgmeWrapper): return plainbytes, result def keylist(self, pattern=None, secret=False, - mode=constants.keylist.mode.LOCAL): + mode=constants.keylist.mode.LOCAL, + source=None): """List keys Keyword arguments: pattern -- return keys matching pattern (default: all keys) secret -- return only secret keys (default: False) mode -- keylist mode (default: list local keys) + source -- read keys from source instead from the keyring + (all other options are ignored in this case) Returns: -- an iterator returning key objects @@ -498,8 +501,22 @@ class Context(GpgmeWrapper): Raises: GPGMEError -- as signaled by the underlying library """ - self.set_keylist_mode(mode) - return self.op_keylist_all(pattern, secret) + if not source: + self.set_keylist_mode(mode) + self.op_keylist_start(pattern, secret) + else: + # Automatic wrapping of SOURCE is not possible here, + # because the object must not be deallocated until the + # iteration over the results ends. + if not isinstance(source, Data): + source = Data(file=source) + self.op_keylist_from_data_start(source, 0) + + key = self.op_keylist_next() + while key: + yield key + key = self.op_keylist_next() + self.op_keylist_end() def create_key(self, userid, algorithm=None, expires_in=0, expires=True, sign=False, encrypt=False, certify=False, authenticate=False, |