python: Improve engine information handling.
* lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos. * lang/python/pyme/core.py (Context.engine_info): New property. (Context.{g,s}et_engine_info): Improve docstrings. * lang/python/pyme/results.py (EngineInfo): New class. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
78f7bf4dcf
commit
355d707286
@ -324,7 +324,7 @@
|
|||||||
|
|
||||||
// Make types containing 'next' field to be lists
|
// Make types containing 'next' field to be lists
|
||||||
%ignore next;
|
%ignore next;
|
||||||
%typemap(out) gpgme_sig_notation_t, gpgme_engine_info_t, gpgme_subkey_t,
|
%typemap(out) gpgme_sig_notation_t, gpgme_subkey_t,
|
||||||
gpgme_key_sig_t, gpgme_user_id_t, gpgme_invalid_key_t,
|
gpgme_key_sig_t, gpgme_user_id_t, gpgme_invalid_key_t,
|
||||||
gpgme_recipient_t, gpgme_new_signature_t, gpgme_signature_t,
|
gpgme_recipient_t, gpgme_new_signature_t, gpgme_signature_t,
|
||||||
gpgme_import_status_t, gpgme_conf_arg_t, gpgme_conf_opt_t,
|
gpgme_import_status_t, gpgme_conf_arg_t, gpgme_conf_opt_t,
|
||||||
@ -409,6 +409,26 @@
|
|||||||
Py_DECREF(fragile);
|
Py_DECREF(fragile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(out) gpgme_engine_info_t {
|
||||||
|
int i;
|
||||||
|
int size = 0;
|
||||||
|
$1_ltype curr;
|
||||||
|
for (curr = $1; curr != NULL; curr = curr->next) {
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
$result = PyList_New(size);
|
||||||
|
for (i=0,curr=$1; i<size; i++,curr=curr->next) {
|
||||||
|
PyObject *fragile, *o;
|
||||||
|
fragile = SWIG_NewPointerObj(SWIG_as_voidptr(curr), $1_descriptor,
|
||||||
|
%newpointer_flags);
|
||||||
|
o = pygpgme_wrap_fragile_result(fragile, "EngineInfo");
|
||||||
|
if (o == NULL)
|
||||||
|
return NULL; /* raise */
|
||||||
|
Py_DECREF(fragile);
|
||||||
|
PyList_SetItem($result, i, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Include mapper for edit callbacks
|
// Include mapper for edit callbacks
|
||||||
|
@ -666,17 +666,39 @@ class Context(GpgmeWrapper):
|
|||||||
if pygpgme.pygpgme_set_status_cb:
|
if pygpgme.pygpgme_set_status_cb:
|
||||||
self.set_status_cb(None)
|
self.set_status_cb(None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def engine_info(self):
|
||||||
|
"""Configuration of the engine currently in use"""
|
||||||
|
p = self.protocol
|
||||||
|
infos = [i for i in self.get_engine_info() if i.protocol == p]
|
||||||
|
assert len(infos) == 1
|
||||||
|
return infos[0]
|
||||||
|
|
||||||
def get_engine_info(self):
|
def get_engine_info(self):
|
||||||
"""Returns this context specific engine info"""
|
"""Get engine configuration
|
||||||
|
|
||||||
|
Returns information about all configured and installed
|
||||||
|
engines.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
infos -- a list of engine infos
|
||||||
|
|
||||||
|
"""
|
||||||
return pygpgme.gpgme_ctx_get_engine_info(self.wrapped)
|
return pygpgme.gpgme_ctx_get_engine_info(self.wrapped)
|
||||||
|
|
||||||
def set_engine_info(self, proto, file_name, home_dir=None):
|
def set_engine_info(self, proto, file_name=None, home_dir=None):
|
||||||
"""Changes the configuration of the crypto engine implementing the
|
"""Change engine configuration
|
||||||
protocol 'proto' for the context. 'file_name' is the file name of
|
|
||||||
the executable program implementing this protocol. 'home_dir' is the
|
Changes the configuration of the crypto engine implementing
|
||||||
directory name of the configuration directory (engine's default is
|
the protocol 'proto' for the context.
|
||||||
used if omitted)."""
|
|
||||||
errorcheck(pygpgme.gpgme_ctx_set_engine_info(self.wrapped, proto, file_name, home_dir))
|
Keyword arguments:
|
||||||
|
file_name -- engine program file name (unchanged if None)
|
||||||
|
home_dir -- configuration directory (unchanged if None)
|
||||||
|
|
||||||
|
"""
|
||||||
|
errorcheck(pygpgme.gpgme_ctx_set_engine_info(
|
||||||
|
self.wrapped, proto, file_name, home_dir))
|
||||||
|
|
||||||
def wait(self, hang):
|
def wait(self, hang):
|
||||||
"""Wait for asynchronous call to finish. Wait forever if hang is True.
|
"""Wait for asynchronous call to finish. Wait forever if hang is True.
|
||||||
|
@ -113,3 +113,6 @@ class KeylistResult(Result):
|
|||||||
|
|
||||||
class VFSMountResult(Result):
|
class VFSMountResult(Result):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class EngineInfo(Result):
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user