python: Rename compiled SWIG module.
Avoid the name pygpgme, as this is the name of another popular Python binding for GPGME. This commit renames the compiled Python module produced by SWIG. * lang/python/Makefile.am: Rename the compiled Python module. * lang/python/gpgme.i: Likewise. * lang/python/pyme/core.py: Likewise. * lang/python/pyme/errors.py: Likewise. * lang/python/pyme/util.py: Likewise. * lang/python/pyme/version.py.in: Likewise. * lang/python/setup.py.in: Likewise. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
b5aa05c3b2
commit
2f754440f2
@ -58,7 +58,7 @@ sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
|
|||||||
upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
|
upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
|
||||||
twine upload $^
|
twine upload $^
|
||||||
|
|
||||||
CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/pygpgme.py \
|
CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
|
||||||
copystamp
|
copystamp
|
||||||
|
|
||||||
# Remove the rest.
|
# Remove the rest.
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
%module pygpgme
|
%module gpgme
|
||||||
%include "cpointer.i"
|
%include "cpointer.i"
|
||||||
%include "cstring.i"
|
%include "cstring.i"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ and the 'Data' class describing buffers of data.
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import weakref
|
import weakref
|
||||||
from . import pygpgme
|
from . import gpgme
|
||||||
from .errors import errorcheck, GPGMEError
|
from .errors import errorcheck, GPGMEError
|
||||||
from . import constants
|
from . import constants
|
||||||
from . import errors
|
from . import errors
|
||||||
@ -93,9 +93,9 @@ class GpgmeWrapper(object):
|
|||||||
_boolean_properties = set()
|
_boolean_properties = set()
|
||||||
|
|
||||||
def __wrap_boolean_property(self, key, do_set=False, value=None):
|
def __wrap_boolean_property(self, key, do_set=False, value=None):
|
||||||
get_func = getattr(pygpgme,
|
get_func = getattr(gpgme,
|
||||||
"{}get_{}".format(self._cprefix, key))
|
"{}get_{}".format(self._cprefix, key))
|
||||||
set_func = getattr(pygpgme,
|
set_func = getattr(gpgme,
|
||||||
"{}set_{}".format(self._cprefix, key))
|
"{}set_{}".format(self._cprefix, key))
|
||||||
def get(slf):
|
def get(slf):
|
||||||
return bool(get_func(slf.wrapped))
|
return bool(get_func(slf.wrapped))
|
||||||
@ -120,19 +120,19 @@ class GpgmeWrapper(object):
|
|||||||
return self.__wrap_boolean_property(key)
|
return self.__wrap_boolean_property(key)
|
||||||
|
|
||||||
name = self._cprefix + key
|
name = self._cprefix + key
|
||||||
func = getattr(pygpgme, name)
|
func = getattr(gpgme, name)
|
||||||
|
|
||||||
if self._errorcheck(name):
|
if self._errorcheck(name):
|
||||||
def _funcwrap(slf, *args):
|
def _funcwrap(slf, *args):
|
||||||
result = func(slf.wrapped, *args)
|
result = func(slf.wrapped, *args)
|
||||||
if slf._callback_excinfo:
|
if slf._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(slf)
|
gpgme.pyme_raise_callback_exception(slf)
|
||||||
return errorcheck(result, "Invocation of " + name)
|
return errorcheck(result, "Invocation of " + name)
|
||||||
else:
|
else:
|
||||||
def _funcwrap(slf, *args):
|
def _funcwrap(slf, *args):
|
||||||
result = func(slf.wrapped, *args)
|
result = func(slf.wrapped, *args)
|
||||||
if slf._callback_excinfo:
|
if slf._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(slf)
|
gpgme.pyme_raise_callback_exception(slf)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
doc = self._munge_docstring.sub(r'\2.\1(\3', getattr(func, "__doc__"))
|
doc = self._munge_docstring.sub(r'\2.\1(\3', getattr(func, "__doc__"))
|
||||||
@ -186,10 +186,10 @@ class Context(GpgmeWrapper):
|
|||||||
if wrapped:
|
if wrapped:
|
||||||
self.own = False
|
self.own = False
|
||||||
else:
|
else:
|
||||||
tmp = pygpgme.new_gpgme_ctx_t_p()
|
tmp = gpgme.new_gpgme_ctx_t_p()
|
||||||
errorcheck(pygpgme.gpgme_new(tmp))
|
errorcheck(gpgme.gpgme_new(tmp))
|
||||||
wrapped = pygpgme.gpgme_ctx_t_p_value(tmp)
|
wrapped = gpgme.gpgme_ctx_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_ctx_t_p(tmp)
|
gpgme.delete_gpgme_ctx_t_p(tmp)
|
||||||
self.own = True
|
self.own = True
|
||||||
super().__init__(wrapped)
|
super().__init__(wrapped)
|
||||||
self.armor = armor
|
self.armor = armor
|
||||||
@ -497,9 +497,9 @@ class Context(GpgmeWrapper):
|
|||||||
else:
|
else:
|
||||||
cmd = " ".join(util.percent_escape(f) for f in command)
|
cmd = " ".join(util.percent_escape(f) for f in command)
|
||||||
|
|
||||||
errptr = pygpgme.new_gpgme_error_t_p()
|
errptr = gpgme.new_gpgme_error_t_p()
|
||||||
|
|
||||||
err = pygpgme.gpgme_op_assuan_transact_ext(
|
err = gpgme.gpgme_op_assuan_transact_ext(
|
||||||
self.wrapped,
|
self.wrapped,
|
||||||
cmd,
|
cmd,
|
||||||
(weakref.ref(self), data_cb) if data_cb else None,
|
(weakref.ref(self), data_cb) if data_cb else None,
|
||||||
@ -508,12 +508,12 @@ class Context(GpgmeWrapper):
|
|||||||
errptr)
|
errptr)
|
||||||
|
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
|
|
||||||
errorcheck(err)
|
errorcheck(err)
|
||||||
|
|
||||||
status = pygpgme.gpgme_error_t_p_value(errptr)
|
status = gpgme.gpgme_error_t_p_value(errptr)
|
||||||
pygpgme.delete_gpgme_error_t_p(errptr)
|
gpgme.delete_gpgme_error_t_p(errptr)
|
||||||
|
|
||||||
return GPGMEError(status) if status != 0 else None
|
return GPGMEError(status) if status != 0 else None
|
||||||
|
|
||||||
@ -565,15 +565,15 @@ class Context(GpgmeWrapper):
|
|||||||
_boolean_properties = {'armor', 'textmode', 'offline'}
|
_boolean_properties = {'armor', 'textmode', 'offline'}
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not pygpgme:
|
if not gpgme:
|
||||||
# At interpreter shutdown, pygpgme is set to NONE.
|
# At interpreter shutdown, gpgme is set to NONE.
|
||||||
return
|
return
|
||||||
|
|
||||||
self._free_passcb()
|
self._free_passcb()
|
||||||
self._free_progresscb()
|
self._free_progresscb()
|
||||||
self._free_statuscb()
|
self._free_statuscb()
|
||||||
if self.own and self.wrapped and pygpgme.gpgme_release:
|
if self.own and self.wrapped and gpgme.gpgme_release:
|
||||||
pygpgme.gpgme_release(self.wrapped)
|
gpgme.gpgme_release(self.wrapped)
|
||||||
self.wrapped = None
|
self.wrapped = None
|
||||||
|
|
||||||
# Implement the context manager protocol.
|
# Implement the context manager protocol.
|
||||||
@ -594,27 +594,27 @@ class Context(GpgmeWrapper):
|
|||||||
"""Returns the next key in the list created
|
"""Returns the next key in the list created
|
||||||
by a call to op_keylist_start(). The object returned
|
by a call to op_keylist_start(). The object returned
|
||||||
is of type Key."""
|
is of type Key."""
|
||||||
ptr = pygpgme.new_gpgme_key_t_p()
|
ptr = gpgme.new_gpgme_key_t_p()
|
||||||
try:
|
try:
|
||||||
errorcheck(pygpgme.gpgme_op_keylist_next(self.wrapped, ptr))
|
errorcheck(gpgme.gpgme_op_keylist_next(self.wrapped, ptr))
|
||||||
key = pygpgme.gpgme_key_t_p_value(ptr)
|
key = gpgme.gpgme_key_t_p_value(ptr)
|
||||||
except errors.GPGMEError as excp:
|
except errors.GPGMEError as excp:
|
||||||
key = None
|
key = None
|
||||||
if excp.getcode() != errors.EOF:
|
if excp.getcode() != errors.EOF:
|
||||||
raise excp
|
raise excp
|
||||||
pygpgme.delete_gpgme_key_t_p(ptr)
|
gpgme.delete_gpgme_key_t_p(ptr)
|
||||||
if key:
|
if key:
|
||||||
key.__del__ = lambda self: pygpgme.gpgme_key_unref(self)
|
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def get_key(self, fpr, secret):
|
def get_key(self, fpr, secret):
|
||||||
"""Return the key corresponding to the fingerprint 'fpr'"""
|
"""Return the key corresponding to the fingerprint 'fpr'"""
|
||||||
ptr = pygpgme.new_gpgme_key_t_p()
|
ptr = gpgme.new_gpgme_key_t_p()
|
||||||
errorcheck(pygpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
|
errorcheck(gpgme.gpgme_get_key(self.wrapped, fpr, ptr, secret))
|
||||||
key = pygpgme.gpgme_key_t_p_value(ptr)
|
key = gpgme.gpgme_key_t_p_value(ptr)
|
||||||
pygpgme.delete_gpgme_key_t_p(ptr)
|
gpgme.delete_gpgme_key_t_p(ptr)
|
||||||
if key:
|
if key:
|
||||||
key.__del__ = lambda self: pygpgme.gpgme_key_unref(self)
|
key.__del__ = lambda self: gpgme.gpgme_key_unref(self)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def op_trustlist_all(self, *args, **kwargs):
|
def op_trustlist_all(self, *args, **kwargs):
|
||||||
@ -629,15 +629,15 @@ class Context(GpgmeWrapper):
|
|||||||
"""Returns the next trust item in the list created
|
"""Returns the next trust item in the list created
|
||||||
by a call to op_trustlist_start(). The object returned
|
by a call to op_trustlist_start(). The object returned
|
||||||
is of type TrustItem."""
|
is of type TrustItem."""
|
||||||
ptr = pygpgme.new_gpgme_trust_item_t_p()
|
ptr = gpgme.new_gpgme_trust_item_t_p()
|
||||||
try:
|
try:
|
||||||
errorcheck(pygpgme.gpgme_op_trustlist_next(self.wrapped, ptr))
|
errorcheck(gpgme.gpgme_op_trustlist_next(self.wrapped, ptr))
|
||||||
trust = pygpgme.gpgme_trust_item_t_p_value(ptr)
|
trust = gpgme.gpgme_trust_item_t_p_value(ptr)
|
||||||
except errors.GPGMEError as excp:
|
except errors.GPGMEError as excp:
|
||||||
trust = None
|
trust = None
|
||||||
if excp.getcode() != errors.EOF:
|
if excp.getcode() != errors.EOF:
|
||||||
raise
|
raise
|
||||||
pygpgme.delete_gpgme_trust_item_t_p(ptr)
|
gpgme.delete_gpgme_trust_item_t_p(ptr)
|
||||||
return trust
|
return trust
|
||||||
|
|
||||||
def set_passphrase_cb(self, func, hook=None):
|
def set_passphrase_cb(self, func, hook=None):
|
||||||
@ -661,10 +661,10 @@ class Context(GpgmeWrapper):
|
|||||||
hookdata = (weakref.ref(self), func)
|
hookdata = (weakref.ref(self), func)
|
||||||
else:
|
else:
|
||||||
hookdata = (weakref.ref(self), func, hook)
|
hookdata = (weakref.ref(self), func, hook)
|
||||||
pygpgme.pyme_set_passphrase_cb(self, hookdata)
|
gpgme.pyme_set_passphrase_cb(self, hookdata)
|
||||||
|
|
||||||
def _free_passcb(self):
|
def _free_passcb(self):
|
||||||
if pygpgme.pyme_set_passphrase_cb:
|
if gpgme.pyme_set_passphrase_cb:
|
||||||
self.set_passphrase_cb(None)
|
self.set_passphrase_cb(None)
|
||||||
|
|
||||||
def set_progress_cb(self, func, hook=None):
|
def set_progress_cb(self, func, hook=None):
|
||||||
@ -686,10 +686,10 @@ class Context(GpgmeWrapper):
|
|||||||
hookdata = (weakref.ref(self), func)
|
hookdata = (weakref.ref(self), func)
|
||||||
else:
|
else:
|
||||||
hookdata = (weakref.ref(self), func, hook)
|
hookdata = (weakref.ref(self), func, hook)
|
||||||
pygpgme.pyme_set_progress_cb(self, hookdata)
|
gpgme.pyme_set_progress_cb(self, hookdata)
|
||||||
|
|
||||||
def _free_progresscb(self):
|
def _free_progresscb(self):
|
||||||
if pygpgme.pyme_set_progress_cb:
|
if gpgme.pyme_set_progress_cb:
|
||||||
self.set_progress_cb(None)
|
self.set_progress_cb(None)
|
||||||
|
|
||||||
def set_status_cb(self, func, hook=None):
|
def set_status_cb(self, func, hook=None):
|
||||||
@ -710,10 +710,10 @@ class Context(GpgmeWrapper):
|
|||||||
hookdata = (weakref.ref(self), func)
|
hookdata = (weakref.ref(self), func)
|
||||||
else:
|
else:
|
||||||
hookdata = (weakref.ref(self), func, hook)
|
hookdata = (weakref.ref(self), func, hook)
|
||||||
pygpgme.pyme_set_status_cb(self, hookdata)
|
gpgme.pyme_set_status_cb(self, hookdata)
|
||||||
|
|
||||||
def _free_statuscb(self):
|
def _free_statuscb(self):
|
||||||
if pygpgme.pyme_set_status_cb:
|
if gpgme.pyme_set_status_cb:
|
||||||
self.set_status_cb(None)
|
self.set_status_cb(None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -734,7 +734,7 @@ class Context(GpgmeWrapper):
|
|||||||
infos -- a list of engine infos
|
infos -- a list of engine infos
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return pygpgme.gpgme_ctx_get_engine_info(self.wrapped)
|
return gpgme.gpgme_ctx_get_engine_info(self.wrapped)
|
||||||
|
|
||||||
def set_engine_info(self, proto, file_name=None, home_dir=None):
|
def set_engine_info(self, proto, file_name=None, home_dir=None):
|
||||||
"""Change engine configuration
|
"""Change engine configuration
|
||||||
@ -747,7 +747,7 @@ class Context(GpgmeWrapper):
|
|||||||
home_dir -- configuration directory (unchanged if None)
|
home_dir -- configuration directory (unchanged if None)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
errorcheck(pygpgme.gpgme_ctx_set_engine_info(
|
errorcheck(gpgme.gpgme_ctx_set_engine_info(
|
||||||
self.wrapped, proto, file_name, home_dir))
|
self.wrapped, proto, file_name, home_dir))
|
||||||
|
|
||||||
def wait(self, hang):
|
def wait(self, hang):
|
||||||
@ -757,10 +757,10 @@ class Context(GpgmeWrapper):
|
|||||||
Please read the GPGME manual for more information.
|
Please read the GPGME manual for more information.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ptr = pygpgme.new_gpgme_error_t_p()
|
ptr = gpgme.new_gpgme_error_t_p()
|
||||||
pygpgme.gpgme_wait(self.wrapped, ptr, hang)
|
gpgme.gpgme_wait(self.wrapped, ptr, hang)
|
||||||
status = pygpgme.gpgme_error_t_p_value(ptr)
|
status = gpgme.gpgme_error_t_p_value(ptr)
|
||||||
pygpgme.delete_gpgme_error_t_p(ptr)
|
gpgme.delete_gpgme_error_t_p(ptr)
|
||||||
errorcheck(status)
|
errorcheck(status)
|
||||||
|
|
||||||
def op_edit(self, key, func, fnc_value, out):
|
def op_edit(self, key, func, fnc_value, out):
|
||||||
@ -772,9 +772,9 @@ class Context(GpgmeWrapper):
|
|||||||
else:
|
else:
|
||||||
opaquedata = (weakref.ref(self), func)
|
opaquedata = (weakref.ref(self), func)
|
||||||
|
|
||||||
result = pygpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)
|
result = gpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
errorcheck(result)
|
errorcheck(result)
|
||||||
|
|
||||||
class Data(GpgmeWrapper):
|
class Data(GpgmeWrapper):
|
||||||
@ -866,14 +866,14 @@ class Data(GpgmeWrapper):
|
|||||||
self.new()
|
self.new()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if not pygpgme:
|
if not gpgme:
|
||||||
# At interpreter shutdown, pygpgme is set to NONE.
|
# At interpreter shutdown, gpgme is set to NONE.
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.wrapped != None and pygpgme.gpgme_data_release:
|
if self.wrapped != None and gpgme.gpgme_data_release:
|
||||||
pygpgme.gpgme_data_release(self.wrapped)
|
gpgme.gpgme_data_release(self.wrapped)
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
self.wrapped = None
|
self.wrapped = None
|
||||||
self._free_datacbs()
|
self._free_datacbs()
|
||||||
|
|
||||||
@ -887,40 +887,40 @@ class Data(GpgmeWrapper):
|
|||||||
self._data_cbs = None
|
self._data_cbs = None
|
||||||
|
|
||||||
def new(self):
|
def new(self):
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
errorcheck(pygpgme.gpgme_data_new(tmp))
|
errorcheck(gpgme.gpgme_data_new(tmp))
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_mem(self, string, copy=True):
|
def new_from_mem(self, string, copy=True):
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
errorcheck(pygpgme.gpgme_data_new_from_mem(tmp,string,len(string),copy))
|
errorcheck(gpgme.gpgme_data_new_from_mem(tmp,string,len(string),copy))
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_file(self, filename, copy=True):
|
def new_from_file(self, filename, copy=True):
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
try:
|
try:
|
||||||
errorcheck(pygpgme.gpgme_data_new_from_file(tmp, filename, copy))
|
errorcheck(gpgme.gpgme_data_new_from_file(tmp, filename, copy))
|
||||||
except errors.GPGMEError as e:
|
except errors.GPGMEError as e:
|
||||||
if e.getcode() == errors.INV_VALUE and not copy:
|
if e.getcode() == errors.INV_VALUE and not copy:
|
||||||
raise ValueError("delayed reads are not yet supported")
|
raise ValueError("delayed reads are not yet supported")
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_cbs(self, read_cb, write_cb, seek_cb, release_cb, hook=None):
|
def new_from_cbs(self, read_cb, write_cb, seek_cb, release_cb, hook=None):
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
if hook != None:
|
if hook != None:
|
||||||
hookdata = (weakref.ref(self),
|
hookdata = (weakref.ref(self),
|
||||||
read_cb, write_cb, seek_cb, release_cb, hook)
|
read_cb, write_cb, seek_cb, release_cb, hook)
|
||||||
else:
|
else:
|
||||||
hookdata = (weakref.ref(self),
|
hookdata = (weakref.ref(self),
|
||||||
read_cb, write_cb, seek_cb, release_cb)
|
read_cb, write_cb, seek_cb, release_cb)
|
||||||
pygpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
|
gpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_filepart(self, file, offset, length):
|
def new_from_filepart(self, file, offset, length):
|
||||||
"""This wraps the GPGME gpgme_data_new_from_filepart() function.
|
"""This wraps the GPGME gpgme_data_new_from_filepart() function.
|
||||||
@ -931,22 +931,22 @@ class Data(GpgmeWrapper):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
filename = None
|
filename = None
|
||||||
fp = None
|
fp = None
|
||||||
|
|
||||||
if type(file) == type("x"):
|
if type(file) == type("x"):
|
||||||
filename = file
|
filename = file
|
||||||
else:
|
else:
|
||||||
fp = pygpgme.fdopen(file.fileno(), file.mode)
|
fp = gpgme.fdopen(file.fileno(), file.mode)
|
||||||
if fp == None:
|
if fp == None:
|
||||||
raise ValueError("Failed to open file from %s arg %s" % \
|
raise ValueError("Failed to open file from %s arg %s" % \
|
||||||
(str(type(file)), str(file)))
|
(str(type(file)), str(file)))
|
||||||
|
|
||||||
errorcheck(pygpgme.gpgme_data_new_from_filepart(tmp, filename, fp,
|
errorcheck(gpgme.gpgme_data_new_from_filepart(tmp, filename, fp,
|
||||||
offset, length))
|
offset, length))
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_fd(self, file):
|
def new_from_fd(self, file):
|
||||||
"""This wraps the GPGME gpgme_data_new_from_fd() function. The
|
"""This wraps the GPGME gpgme_data_new_from_fd() function. The
|
||||||
@ -954,10 +954,10 @@ class Data(GpgmeWrapper):
|
|||||||
fileno() method.
|
fileno() method.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
tmp = pygpgme.new_gpgme_data_t_p()
|
tmp = gpgme.new_gpgme_data_t_p()
|
||||||
errorcheck(pygpgme.gpgme_data_new_from_fd(tmp, file.fileno()))
|
errorcheck(gpgme.gpgme_data_new_from_fd(tmp, file.fileno()))
|
||||||
self.wrapped = pygpgme.gpgme_data_t_p_value(tmp)
|
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||||
pygpgme.delete_gpgme_data_t_p(tmp)
|
gpgme.delete_gpgme_data_t_p(tmp)
|
||||||
|
|
||||||
def new_from_stream(self, file):
|
def new_from_stream(self, file):
|
||||||
"""This wrap around gpgme_data_new_from_stream is an alias for
|
"""This wrap around gpgme_data_new_from_stream is an alias for
|
||||||
@ -969,10 +969,10 @@ class Data(GpgmeWrapper):
|
|||||||
"""Write buffer given as string or bytes.
|
"""Write buffer given as string or bytes.
|
||||||
|
|
||||||
If a string is given, it is implicitly encoded using UTF-8."""
|
If a string is given, it is implicitly encoded using UTF-8."""
|
||||||
written = pygpgme.gpgme_data_write(self.wrapped, buffer)
|
written = gpgme.gpgme_data_write(self.wrapped, buffer)
|
||||||
if written < 0:
|
if written < 0:
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
else:
|
else:
|
||||||
raise GPGMEError.fromSyserror()
|
raise GPGMEError.fromSyserror()
|
||||||
return written
|
return written
|
||||||
@ -990,10 +990,10 @@ class Data(GpgmeWrapper):
|
|||||||
|
|
||||||
if size > 0:
|
if size > 0:
|
||||||
try:
|
try:
|
||||||
result = pygpgme.gpgme_data_read(self.wrapped, size)
|
result = gpgme.gpgme_data_read(self.wrapped, size)
|
||||||
except:
|
except:
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
return result
|
return result
|
||||||
@ -1001,10 +1001,10 @@ class Data(GpgmeWrapper):
|
|||||||
chunks = []
|
chunks = []
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
result = pygpgme.gpgme_data_read(self.wrapped, 4096)
|
result = gpgme.gpgme_data_read(self.wrapped, 4096)
|
||||||
except:
|
except:
|
||||||
if self._callback_excinfo:
|
if self._callback_excinfo:
|
||||||
pygpgme.pyme_raise_callback_exception(self)
|
gpgme.pyme_raise_callback_exception(self)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
if len(result) == 0:
|
if len(result) == 0:
|
||||||
@ -1013,16 +1013,16 @@ class Data(GpgmeWrapper):
|
|||||||
return b''.join(chunks)
|
return b''.join(chunks)
|
||||||
|
|
||||||
def pubkey_algo_name(algo):
|
def pubkey_algo_name(algo):
|
||||||
return pygpgme.gpgme_pubkey_algo_name(algo)
|
return gpgme.gpgme_pubkey_algo_name(algo)
|
||||||
|
|
||||||
def hash_algo_name(algo):
|
def hash_algo_name(algo):
|
||||||
return pygpgme.gpgme_hash_algo_name(algo)
|
return gpgme.gpgme_hash_algo_name(algo)
|
||||||
|
|
||||||
def get_protocol_name(proto):
|
def get_protocol_name(proto):
|
||||||
return pygpgme.gpgme_get_protocol_name(proto)
|
return gpgme.gpgme_get_protocol_name(proto)
|
||||||
|
|
||||||
def check_version(version=None):
|
def check_version(version=None):
|
||||||
return pygpgme.gpgme_check_version(version)
|
return gpgme.gpgme_check_version(version)
|
||||||
|
|
||||||
# check_version also makes sure that several subsystems are properly
|
# check_version also makes sure that several subsystems are properly
|
||||||
# initialized, and it must be run at least once before invoking any
|
# initialized, and it must be run at least once before invoking any
|
||||||
@ -1032,19 +1032,19 @@ check_version()
|
|||||||
|
|
||||||
def engine_check_version (proto):
|
def engine_check_version (proto):
|
||||||
try:
|
try:
|
||||||
errorcheck(pygpgme.gpgme_engine_check_version(proto))
|
errorcheck(gpgme.gpgme_engine_check_version(proto))
|
||||||
return True
|
return True
|
||||||
except errors.GPGMEError:
|
except errors.GPGMEError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_engine_info():
|
def get_engine_info():
|
||||||
ptr = pygpgme.new_gpgme_engine_info_t_p()
|
ptr = gpgme.new_gpgme_engine_info_t_p()
|
||||||
try:
|
try:
|
||||||
errorcheck(pygpgme.gpgme_get_engine_info(ptr))
|
errorcheck(gpgme.gpgme_get_engine_info(ptr))
|
||||||
info = pygpgme.gpgme_engine_info_t_p_value(ptr)
|
info = gpgme.gpgme_engine_info_t_p_value(ptr)
|
||||||
except errors.GPGMEError:
|
except errors.GPGMEError:
|
||||||
info = None
|
info = None
|
||||||
pygpgme.delete_gpgme_engine_info_t_p(ptr)
|
gpgme.delete_gpgme_engine_info_t_p(ptr)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def set_engine_info(proto, file_name, home_dir=None):
|
def set_engine_info(proto, file_name, home_dir=None):
|
||||||
@ -1053,11 +1053,11 @@ def set_engine_info(proto, file_name, home_dir=None):
|
|||||||
the executable program implementing this protocol. 'home_dir' is the
|
the executable program implementing this protocol. 'home_dir' is the
|
||||||
directory name of the configuration directory (engine's default is
|
directory name of the configuration directory (engine's default is
|
||||||
used if omitted)."""
|
used if omitted)."""
|
||||||
errorcheck(pygpgme.gpgme_set_engine_info(proto, file_name, home_dir))
|
errorcheck(gpgme.gpgme_set_engine_info(proto, file_name, home_dir))
|
||||||
|
|
||||||
def set_locale(category, value):
|
def set_locale(category, value):
|
||||||
"""Sets the default locale used by contexts"""
|
"""Sets the default locale used by contexts"""
|
||||||
errorcheck(pygpgme.gpgme_set_locale(None, category, value))
|
errorcheck(gpgme.gpgme_set_locale(None, category, value))
|
||||||
|
|
||||||
def wait(hang):
|
def wait(hang):
|
||||||
"""Wait for asynchronous call on any Context to finish.
|
"""Wait for asynchronous call on any Context to finish.
|
||||||
@ -1068,10 +1068,10 @@ def wait(hang):
|
|||||||
context - context which caused this call to return.
|
context - context which caused this call to return.
|
||||||
|
|
||||||
Please read the GPGME manual of more information."""
|
Please read the GPGME manual of more information."""
|
||||||
ptr = pygpgme.new_gpgme_error_t_p()
|
ptr = gpgme.new_gpgme_error_t_p()
|
||||||
context = pygpgme.gpgme_wait(None, ptr, hang)
|
context = gpgme.gpgme_wait(None, ptr, hang)
|
||||||
status = pygpgme.gpgme_error_t_p_value(ptr)
|
status = gpgme.gpgme_error_t_p_value(ptr)
|
||||||
pygpgme.delete_gpgme_error_t_p(ptr)
|
gpgme.delete_gpgme_error_t_p(ptr)
|
||||||
if context == None:
|
if context == None:
|
||||||
errorcheck(status)
|
errorcheck(status)
|
||||||
else:
|
else:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from . import pygpgme
|
from . import gpgme
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
util.process_constants('GPG_ERR_', globals())
|
util.process_constants('GPG_ERR_', globals())
|
||||||
@ -30,20 +30,20 @@ class GPGMEError(PymeError):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fromSyserror(cls):
|
def fromSyserror(cls):
|
||||||
return cls(pygpgme.gpgme_err_code_from_syserror())
|
return cls(gpgme.gpgme_err_code_from_syserror())
|
||||||
|
|
||||||
def getstring(self):
|
def getstring(self):
|
||||||
message = "%s: %s" % (pygpgme.gpgme_strsource(self.error),
|
message = "%s: %s" % (gpgme.gpgme_strsource(self.error),
|
||||||
pygpgme.gpgme_strerror(self.error))
|
gpgme.gpgme_strerror(self.error))
|
||||||
if self.message != None:
|
if self.message != None:
|
||||||
message = "%s: %s" % (self.message, message)
|
message = "%s: %s" % (self.message, message)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def getcode(self):
|
def getcode(self):
|
||||||
return pygpgme.gpgme_err_code(self.error)
|
return gpgme.gpgme_err_code(self.error)
|
||||||
|
|
||||||
def getsource(self):
|
def getsource(self):
|
||||||
return pygpgme.gpgme_err_source(self.error)
|
return gpgme.gpgme_err_source(self.error)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.getstring()
|
return self.getstring()
|
||||||
@ -62,7 +62,7 @@ class InvalidRecipients(EncryptionError):
|
|||||||
self.recipients = recipients
|
self.recipients = recipients
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ", ".join("{}: {}".format(r.fpr,
|
return ", ".join("{}: {}".format(r.fpr,
|
||||||
pygpgme.gpgme_strerror(r.reason))
|
gpgme.gpgme_strerror(r.reason))
|
||||||
for r in self.recipients)
|
for r in self.recipients)
|
||||||
|
|
||||||
class DeryptionError(PymeError):
|
class DeryptionError(PymeError):
|
||||||
@ -82,7 +82,7 @@ class InvalidSigners(SigningError):
|
|||||||
self.signers = signers
|
self.signers = signers
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ", ".join("{}: {}".format(s.fpr,
|
return ", ".join("{}: {}".format(s.fpr,
|
||||||
pygpgme.gpgme_strerror(s.reason))
|
gpgme.gpgme_strerror(s.reason))
|
||||||
for s in self.signers)
|
for s in self.signers)
|
||||||
|
|
||||||
class VerificationError(PymeError):
|
class VerificationError(PymeError):
|
||||||
@ -93,7 +93,7 @@ class BadSignatures(VerificationError):
|
|||||||
self.result = result
|
self.result = result
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ", ".join("{}: {}".format(s.fpr,
|
return ", ".join("{}: {}".format(s.fpr,
|
||||||
pygpgme.gpgme_strerror(s.status))
|
gpgme.gpgme_strerror(s.status))
|
||||||
for s in self.result.signatures
|
for s in self.result.signatures
|
||||||
if s.status != NO_ERROR)
|
if s.status != NO_ERROR)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from . import pygpgme
|
from . import gpgme
|
||||||
|
|
||||||
def process_constants(prefix, scope):
|
def process_constants(prefix, scope):
|
||||||
"""Called by the constant modules to load up the constants from the C
|
"""Called by the constant modules to load up the constants from the C
|
||||||
@ -26,8 +26,8 @@ def process_constants(prefix, scope):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
index = len(prefix)
|
index = len(prefix)
|
||||||
constants = {identifier[index:]: getattr(pygpgme, identifier)
|
constants = {identifier[index:]: getattr(gpgme, identifier)
|
||||||
for identifier in dir(pygpgme)
|
for identifier in dir(gpgme)
|
||||||
if identifier.startswith(prefix)}
|
if identifier.startswith(prefix)}
|
||||||
scope.update(constants)
|
scope.update(constants)
|
||||||
return list(constants.keys())
|
return list(constants.keys())
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from . import pygpgme
|
from . import gpgme
|
||||||
|
|
||||||
productname = 'pyme'
|
productname = 'pyme'
|
||||||
versionstr = "@VERSION@"
|
versionstr = "@VERSION@"
|
||||||
gpgme_versionstr = pygpgme.GPGME_VERSION
|
gpgme_versionstr = gpgme.GPGME_VERSION
|
||||||
|
|
||||||
versionlist = versionstr.split(".")
|
versionlist = versionstr.split(".")
|
||||||
major = versionlist[0]
|
major = versionlist[0]
|
||||||
|
@ -135,7 +135,7 @@ class BuildExtFirstHack(build):
|
|||||||
self.run_command('build_ext')
|
self.run_command('build_ext')
|
||||||
build.run(self)
|
build.run(self)
|
||||||
|
|
||||||
swige = Extension("pyme._pygpgme", ["gpgme.i", "helpers.c"],
|
swige = Extension("pyme._gpgme", ["gpgme.i", "helpers.c"],
|
||||||
swig_opts = ['-py3', '-builtin',
|
swig_opts = ['-py3', '-builtin',
|
||||||
'-outdir', 'pyme'] + extra_swig_opts,
|
'-outdir', 'pyme'] + extra_swig_opts,
|
||||||
include_dirs = include_dirs,
|
include_dirs = include_dirs,
|
||||||
|
Loading…
Reference in New Issue
Block a user