python: Rename Python module from PyME to gpg.
This follows weeks of discussion on the gnupg-devel mailing list. Hopefully it will make it easier for people using Python to use GnuPG in the future. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
This commit is contained in:
parent
b8159eadb5
commit
2fac017618
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
||||
Noteworthy changes in version 1.7.2 (unreleased)
|
||||
------------------------------------------------
|
||||
|
||||
* The module of the Python bindings has been renamed to 'gpg'.
|
||||
|
||||
* Interface changes relative to the 1.7.1 release:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -885,7 +885,7 @@ AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
|
||||
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
|
||||
AC_CONFIG_FILES(lang/qt/doc/Makefile)
|
||||
AC_CONFIG_FILES([lang/python/Makefile
|
||||
lang/python/pyme/version.py
|
||||
lang/python/gpg/version.py
|
||||
lang/python/tests/Makefile])
|
||||
AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
|
||||
AC_OUTPUT
|
||||
|
@ -12,4 +12,4 @@ Directory Language
|
||||
cl Common Lisp
|
||||
cpp C++
|
||||
qt Qt-Framework API
|
||||
python Python 2 and 3 (port of PyME 0.9.0)
|
||||
python Python 2 and 3 (module name: gpg)
|
||||
|
@ -1,4 +1,4 @@
|
||||
recursive-include examples *.py
|
||||
include gpgme-h-clean.py gpgme.i
|
||||
include helpers.c helpers.h private.h
|
||||
recursive-include pyme *.py
|
||||
recursive-include gpg *.py
|
||||
|
@ -23,7 +23,7 @@ EXTRA_DIST = \
|
||||
helpers.c helpers.h private.h \
|
||||
gpgme-h-clean.py \
|
||||
examples \
|
||||
pyme
|
||||
gpg
|
||||
|
||||
SUBDIRS = . tests
|
||||
|
||||
@ -35,21 +35,21 @@ COPY_FILES = \
|
||||
$(srcdir)/examples \
|
||||
$(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
|
||||
|
||||
COPY_FILES_PYME = \
|
||||
$(srcdir)/pyme/callbacks.py \
|
||||
$(srcdir)/pyme/constants \
|
||||
$(srcdir)/pyme/core.py \
|
||||
$(srcdir)/pyme/errors.py \
|
||||
$(srcdir)/pyme/__init__.py \
|
||||
$(srcdir)/pyme/results.py \
|
||||
$(srcdir)/pyme/util.py
|
||||
COPY_FILES_GPG = \
|
||||
$(srcdir)/gpg/callbacks.py \
|
||||
$(srcdir)/gpg/constants \
|
||||
$(srcdir)/gpg/core.py \
|
||||
$(srcdir)/gpg/errors.py \
|
||||
$(srcdir)/gpg/__init__.py \
|
||||
$(srcdir)/gpg/results.py \
|
||||
$(srcdir)/gpg/util.py
|
||||
|
||||
# For VPATH builds we need to copy some files because Python's
|
||||
# distutils are not VPATH-aware.
|
||||
copystamp: $(COPY_FILES) $(COPY_FILES_PYME) data.h config.h
|
||||
copystamp: $(COPY_FILES) $(COPY_FILES_GPG) data.h config.h
|
||||
if test "$(srcdir)" != "$(builddir)" ; then \
|
||||
cp -R $(COPY_FILES) . ; \
|
||||
cp -R $(COPY_FILES_PYME) pyme ; \
|
||||
cp -R $(COPY_FILES_GPG) gpg ; \
|
||||
fi
|
||||
touch $@
|
||||
|
||||
@ -65,22 +65,22 @@ all-local: copystamp
|
||||
$$PYTHON setup.py build --verbose ; \
|
||||
done
|
||||
|
||||
dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
|
||||
dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc: copystamp
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
$(PYTHON) setup.py sdist --verbose
|
||||
gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
|
||||
gpg2 --detach-sign --armor dist/gpg-$(VERSION).tar.gz
|
||||
|
||||
.PHONY: prepare
|
||||
prepare: copystamp
|
||||
|
||||
.PHONY: sdist
|
||||
sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
|
||||
sdist: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
|
||||
|
||||
.PHONY: upload
|
||||
upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
|
||||
upload: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
|
||||
twine upload $^
|
||||
|
||||
CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
|
||||
CLEANFILES = gpgme.h errors.i gpgme_wrap.c gpg/gpgme.py \
|
||||
data.h config.h copystamp
|
||||
|
||||
# Remove the rest.
|
||||
@ -92,8 +92,8 @@ clean-local:
|
||||
if test "$(srcdir)" != "$(builddir)" ; then \
|
||||
find . -type d ! -perm -200 -exec chmod u+w {} ';' ; \
|
||||
for F in $(COPY_FILES); do rm -rf -- `basename $$F` ; done ; \
|
||||
for F in $(COPY_FILES_PYME); do \
|
||||
rm -rf -- pyme/`basename $$F` ; \
|
||||
for F in $(COPY_FILES_GPG); do \
|
||||
rm -rf -- gpg/`basename $$F` ; \
|
||||
done ; \
|
||||
fi
|
||||
|
||||
@ -107,9 +107,9 @@ install-exec-local:
|
||||
cat files.txt >> install_files.txt ; \
|
||||
rm files.txt ; \
|
||||
done
|
||||
$(MKDIR_P) $(DESTDIR)$(pythondir)/pyme
|
||||
mv install_files.txt $(DESTDIR)$(pythondir)/pyme
|
||||
$(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
|
||||
mv install_files.txt $(DESTDIR)$(pythondir)/gpg
|
||||
|
||||
uninstall-local:
|
||||
xargs <$(DESTDIR)$(pythondir)/pyme/install_files.txt -- rm -rf --
|
||||
rm -rf -- $(DESTDIR)$(pythondir)/pyme
|
||||
xargs <$(DESTDIR)$(pythondir)/gpg/install_files.txt -- rm -rf --
|
||||
rm -rf -- $(DESTDIR)$(pythondir)/gpg
|
||||
|
@ -1,10 +1,10 @@
|
||||
PyME - GPGME for Python -*- org -*-
|
||||
gpg - GPGME bindings for Python -*- org -*-
|
||||
=======================
|
||||
|
||||
PyME is a python interface to the GPGME library:
|
||||
The "gpg" module is a python interface to the GPGME library:
|
||||
https://www.gnupg.org/related_software/gpgme/
|
||||
|
||||
PyME offers two interfaces, one is a high-level, curated, and
|
||||
"gpg" offers two interfaces, one is a high-level, curated, and
|
||||
idiomatic interface that is implemented as a shim on top of the
|
||||
low-level interface automatically created using SWIG.
|
||||
|
||||
@ -27,20 +27,22 @@ https://bugs.gnupg.org/gnupg/
|
||||
|
||||
* Authors
|
||||
|
||||
PyME has been created by John Goerzen, and maintained, developed, and
|
||||
PyME was created by John Goerzen, and maintained, developed, and
|
||||
cherished by Igor Belyi, Martin Albrecht, Ben McGinnes, and everyone
|
||||
who contributed to it in any way.
|
||||
|
||||
In 2016 we merged a port of PyME to into the GPGME repository, and
|
||||
development will continue there. Please see the VCS history for the
|
||||
list of contributors, and if you do find bugs, or want to contribute,
|
||||
please get in touch and help maintain PyME.
|
||||
please get in touch and help maintain the python gpg bindings.
|
||||
|
||||
Please see the section 'History' further down this document for
|
||||
references to previous versions.
|
||||
|
||||
* History
|
||||
|
||||
- The python bindings were renamed from PyME to "gpg" in 2016.
|
||||
|
||||
- The bindings have been merged into the GPGME repository in 2016.
|
||||
|
||||
- The latest version of PyME for Python 3.2 and above (as of
|
||||
|
@ -1,6 +1,6 @@
|
||||
=======================
|
||||
A Short History of PyME
|
||||
=======================
|
||||
==========================================
|
||||
A Short History of gpg bindings for Python
|
||||
==========================================
|
||||
|
||||
In 2002 John Goerzen released PyME; Python bindings for the GPGME
|
||||
module which utilised the current release of Python of the time
|
||||
@ -27,6 +27,8 @@ decision to fold the Python 3 port back into the original GPGME
|
||||
release in the languages subdirectory for non-C bindings. Ben is the
|
||||
maintainer of the Python 3 port within GPGME.
|
||||
|
||||
In 2016 PyME was renamed to "gpg" and adopted by the upstream GnuPG
|
||||
team.
|
||||
|
||||
---------------------
|
||||
The Annoyances of Git
|
||||
|
@ -20,9 +20,9 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
with pyme.Context(protocol=pyme.constants.PROTOCOL_ASSUAN) as c:
|
||||
with gpg.Context(protocol=gpg.constants.PROTOCOL_ASSUAN) as c:
|
||||
# Invoke the pinentry to get a confirmation.
|
||||
err = c.assuan_transact(['GET_CONFIRMATION', 'Hello there'])
|
||||
print("You chose {}.".format("cancel" if err else "ok"))
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
"""A decryption filter
|
||||
|
||||
This demonstrates decryption using pyme3 in three lines of code. To
|
||||
This demonstrates decryption using gpg3 in three lines of code. To
|
||||
be used like this:
|
||||
|
||||
./decryption-filter.py <message.gpg >message.plain
|
||||
@ -28,5 +28,5 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
pyme.Context().decrypt(sys.stdin, sink=sys.stdout)
|
||||
import gpg
|
||||
gpg.Context().decrypt(sys.stdin, sink=sys.stdout)
|
||||
|
@ -22,12 +22,12 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
# Note: We must not modify the key store during iteration,
|
||||
# therefore, we explicitly make a list.
|
||||
keys = list(c.keylist("joe+pyme@example.org"))
|
||||
keys = list(c.keylist("joe+gpg@example.org"))
|
||||
|
||||
for k in keys:
|
||||
c.op_delete(k, True)
|
||||
|
@ -26,9 +26,9 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
recipients = list()
|
||||
for key in c.keylist():
|
||||
valid = 0
|
||||
@ -42,7 +42,7 @@ with pyme.Context(armor=True) as c:
|
||||
try:
|
||||
ciphertext, _, _ = c.encrypt(b'This is my message.',
|
||||
recipients=recipients)
|
||||
except pyme.errors.InvalidRecipients as e:
|
||||
except gpg.errors.InvalidRecipients as e:
|
||||
print("Encryption failed for these keys:\n{0!s}".format(e))
|
||||
|
||||
# filter out the bad keys
|
||||
|
@ -17,18 +17,18 @@
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Sample of export and import of keys
|
||||
# It uses keys for joe+pyme@example.org generated by genkey.py script
|
||||
# It uses keys for joe+gpg@example.org generated by genkey.py script
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
user = "joe+pyme@example.org"
|
||||
user = "joe+gpg@example.org"
|
||||
|
||||
with pyme.Context(armor=True) as c, pyme.Data() as expkey:
|
||||
with gpg.Context(armor=True) as c, gpg.Data() as expkey:
|
||||
print(" - Export %s's public keys - " % user)
|
||||
c.op_export(user, 0, expkey)
|
||||
|
||||
@ -43,7 +43,7 @@ with pyme.Context(armor=True) as c, pyme.Data() as expkey:
|
||||
# delete keys to ensure that they came from our imported data. Note
|
||||
# that if joe's key has private part as well we can only delete both
|
||||
# of them.
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
# Note: We must not modify the key store during iteration,
|
||||
# therfore, we explicitly make a list.
|
||||
keys = list(c.keylist(user))
|
||||
@ -51,7 +51,7 @@ with pyme.Context() as c:
|
||||
for k in keys:
|
||||
c.op_delete(k, True)
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
print(" - Import exported keys - ")
|
||||
c.op_import(expstring)
|
||||
result = c.op_import_result()
|
||||
|
@ -20,7 +20,7 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
# This is the example from the GPGME manual.
|
||||
|
||||
@ -31,14 +31,14 @@ Subkey-Type: RSA
|
||||
Subkey-Length: 2048
|
||||
Name-Real: Joe Tester
|
||||
Name-Comment: with stupid passphrase
|
||||
Name-Email: joe+pyme@example.org
|
||||
Name-Email: joe+gpg@example.org
|
||||
Passphrase: Crypt0R0cks
|
||||
Expire-Date: 2020-12-31
|
||||
</GnupgKeyParms>
|
||||
"""
|
||||
|
||||
with pyme.Context() as c:
|
||||
c.set_progress_cb(pyme.callbacks.progress_stdout)
|
||||
with gpg.Context() as c:
|
||||
c.set_progress_cb(gpg.callbacks.progress_stdout)
|
||||
c.op_genkey(parms, None, None)
|
||||
print("Generated key with fingerprint {0}.".format(
|
||||
c.op_genkey_result().fpr))
|
||||
|
@ -22,14 +22,14 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit("Usage: %s <Gpg key pattern>\n" % sys.argv[0])
|
||||
|
||||
name = sys.argv[1]
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
keys = list(c.keylist(name))
|
||||
if len(keys) == 0:
|
||||
sys.exit("No key matching {}.".format(name))
|
||||
|
@ -20,9 +20,9 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
from pyme.constants.sig import mode
|
||||
import gpg
|
||||
from gpg.constants.sig import mode
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
signed, _ = c.sign(b"Test message", mode=mode.CLEAR)
|
||||
sys.stdout.buffer.write(signed)
|
||||
|
@ -17,18 +17,18 @@
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Sample of unattended signing/verifying of a message.
|
||||
# It uses keys for joe+pyme@example.org generated by genkey.py script
|
||||
# It uses keys for joe+gpg@example.org generated by genkey.py script
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
from pyme.constants.sig import mode
|
||||
import gpg
|
||||
from gpg.constants.sig import mode
|
||||
|
||||
user = "joe+pyme"
|
||||
user = "joe+gpg"
|
||||
|
||||
with pyme.Context(pinentry_mode=pyme.constants.PINENTRY_MODE_LOOPBACK) as c:
|
||||
with gpg.Context(pinentry_mode=gpg.constants.PINENTRY_MODE_LOOPBACK) as c:
|
||||
keys = list(c.keylist(user))
|
||||
if len(keys) == 0:
|
||||
sys.exit("No key matching {}.".format(user))
|
||||
|
@ -21,9 +21,9 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
recipients = []
|
||||
print("Enter name of your recipient(s), end with a blank line.")
|
||||
while True:
|
||||
|
@ -22,12 +22,12 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit("fingerprint or unique key ID for gpgme_get_key()")
|
||||
|
||||
with pyme.Context(protocol=pyme.constants.PROTOCOL_CMS) as c:
|
||||
with gpg.Context(protocol=gpg.constants.PROTOCOL_CMS) as c:
|
||||
key = c.get_key(sys.argv[1])
|
||||
|
||||
print("got key: ", key.subkeys[0].fpr)
|
||||
|
@ -21,8 +21,8 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
from pyme import core
|
||||
from pyme.constants import protocol
|
||||
from gpg import core
|
||||
from gpg.constants import protocol
|
||||
|
||||
def print_engine_infos():
|
||||
print("gpgme version:", core.check_version(None))
|
||||
|
@ -16,17 +16,13 @@
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
"""Pyme: GPGME Interface for Python
|
||||
"""gpg: GnuPG Interface for Python (GPGME bindings)
|
||||
|
||||
Welcome to PyME, the GPGME Interface for Python. "Pyme", when prounced,
|
||||
rhymes with "Pine".
|
||||
Welcome to gpg, the GnuPG Interface for Python.
|
||||
|
||||
The latest release of this package may be obtained from
|
||||
https://www.gnupg.org
|
||||
|
||||
Previous releases of this package for Python 2 can be obtained from
|
||||
http://pyme.sourceforge.net
|
||||
|
||||
FEATURES
|
||||
--------
|
||||
|
||||
@ -43,23 +39,23 @@ FEATURES
|
||||
QUICK EXAMPLE
|
||||
-------------
|
||||
|
||||
>>> import pyme
|
||||
>>> with pyme.Context() as c:
|
||||
>>> with pyme.Context() as c:
|
||||
>>> import gpg
|
||||
>>> with gpg.Context() as c:
|
||||
>>> with gpg.Context() as c:
|
||||
... cipher, _, _ = c.encrypt("Hello world :)".encode(),
|
||||
... passphrase="abc")
|
||||
... c.decrypt(cipher, passphrase="abc")
|
||||
...
|
||||
(b'Hello world :)',
|
||||
<pyme.results.DecryptResult object at 0x7f5ab8121080>,
|
||||
<pyme.results.VerifyResult object at 0x7f5ab81219b0>)
|
||||
<gpg.results.DecryptResult object at 0x7f5ab8121080>,
|
||||
<gpg.results.VerifyResult object at 0x7f5ab81219b0>)
|
||||
|
||||
GENERAL OVERVIEW
|
||||
----------------
|
||||
|
||||
For those of you familiar with GPGME, you will be right at home here.
|
||||
|
||||
Pyme is, for the most part, a direct interface to the C GPGME
|
||||
The python gpg module is, for the most part, a direct interface to the C GPGME
|
||||
library. However, it is re-packaged in a more Pythonic way --
|
||||
object-oriented with classes and modules. Take a look at the classes
|
||||
defined here -- they correspond directly to certain object types in GPGME
|
||||
@ -77,7 +73,7 @@ context = core.Context()
|
||||
context.op_encrypt(recp, 1, plain, cipher)
|
||||
|
||||
The Python module automatically does error-checking and raises Python
|
||||
exception pyme.errors.GPGMEError when GPGME signals an error. getcode()
|
||||
exception gpg.errors.GPGMEError when GPGME signals an error. getcode()
|
||||
and getsource() of this exception return code and source of the error.
|
||||
|
||||
IMPORTANT NOTE
|
||||
@ -94,7 +90,7 @@ be found only in GPGME documentation.
|
||||
|
||||
FOR MORE INFORMATION
|
||||
--------------------
|
||||
PYME3 homepage: https://www.gnupg.org/
|
||||
GnuPG homepage: https://www.gnupg.org/
|
||||
GPGME documentation: https://www.gnupg.org/documentation/manuals/gpgme/
|
||||
|
||||
"""
|
@ -2,14 +2,14 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_', globals())
|
||||
|
||||
__all__ = ['data', 'event', 'import', 'keylist', 'md', 'pk',
|
||||
'protocol', 'sig', 'sigsum', 'status', 'validity']
|
||||
|
||||
# GPGME 1.7 replaced gpgme_op_edit with gpgme_op_interact. We
|
||||
# implement pyme.Context.op_edit using gpgme_op_interact, so the
|
||||
# implement gpg.Context.op_edit using gpgme_op_interact, so the
|
||||
# callbacks will be called with string keywords instead of numeric
|
||||
# status messages. Code that is using these constants will continue
|
||||
# to work.
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_DATA_ENCODING_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_EVENT_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_IMPORT_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_KEYLIST_MODE_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_MD_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_PK_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_PROTOCOL_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_SIG_MODE_', globals())
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_SIGSUM_', globals())
|
@ -19,7 +19,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
# GPGME 1.7 replaced gpgme_op_edit with gpgme_op_interact. We
|
||||
# implement pyme.Context.op_edit using gpgme_op_interact, so the
|
||||
# implement gpg.Context.op_edit using gpgme_op_interact, so the
|
||||
# callbacks will be called with string keywords instead of numeric
|
||||
# status messages. Code that is using these constants will continue
|
||||
# to work.
|
@ -18,5 +18,5 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import util
|
||||
from gpg import util
|
||||
util.process_constants('GPGME_VALIDITY_', globals())
|
@ -131,13 +131,13 @@ class GpgmeWrapper(object):
|
||||
def _funcwrap(slf, *args):
|
||||
result = func(slf.wrapped, *args)
|
||||
if slf._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(slf)
|
||||
gpgme.gpg_raise_callback_exception(slf)
|
||||
return errorcheck(result, "Invocation of " + name)
|
||||
else:
|
||||
def _funcwrap(slf, *args):
|
||||
result = func(slf.wrapped, *args)
|
||||
if slf._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(slf)
|
||||
gpgme.gpg_raise_callback_exception(slf)
|
||||
return result
|
||||
|
||||
doc = self._munge_docstring.sub(r'\2.\1(\3', getattr(func, "__doc__"))
|
||||
@ -528,7 +528,7 @@ class Context(GpgmeWrapper):
|
||||
errptr)
|
||||
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
|
||||
errorcheck(err)
|
||||
|
||||
@ -567,7 +567,7 @@ class Context(GpgmeWrapper):
|
||||
result = gpgme.gpgme_op_interact(self.wrapped, key, flags,
|
||||
opaquedata, sink)
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
errorcheck(result)
|
||||
|
||||
@property
|
||||
@ -743,10 +743,10 @@ class Context(GpgmeWrapper):
|
||||
hookdata = (weakref.ref(self), func)
|
||||
else:
|
||||
hookdata = (weakref.ref(self), func, hook)
|
||||
gpgme.pyme_set_passphrase_cb(self, hookdata)
|
||||
gpgme.gpg_set_passphrase_cb(self, hookdata)
|
||||
|
||||
def _free_passcb(self):
|
||||
if gpgme.pyme_set_passphrase_cb:
|
||||
if gpgme.gpg_set_passphrase_cb:
|
||||
self.set_passphrase_cb(None)
|
||||
|
||||
def set_progress_cb(self, func, hook=None):
|
||||
@ -768,10 +768,10 @@ class Context(GpgmeWrapper):
|
||||
hookdata = (weakref.ref(self), func)
|
||||
else:
|
||||
hookdata = (weakref.ref(self), func, hook)
|
||||
gpgme.pyme_set_progress_cb(self, hookdata)
|
||||
gpgme.gpg_set_progress_cb(self, hookdata)
|
||||
|
||||
def _free_progresscb(self):
|
||||
if gpgme.pyme_set_progress_cb:
|
||||
if gpgme.gpg_set_progress_cb:
|
||||
self.set_progress_cb(None)
|
||||
|
||||
def set_status_cb(self, func, hook=None):
|
||||
@ -792,10 +792,10 @@ class Context(GpgmeWrapper):
|
||||
hookdata = (weakref.ref(self), func)
|
||||
else:
|
||||
hookdata = (weakref.ref(self), func, hook)
|
||||
gpgme.pyme_set_status_cb(self, hookdata)
|
||||
gpgme.gpg_set_status_cb(self, hookdata)
|
||||
|
||||
def _free_statuscb(self):
|
||||
if gpgme.pyme_set_status_cb:
|
||||
if gpgme.gpg_set_status_cb:
|
||||
self.set_status_cb(None)
|
||||
|
||||
@property
|
||||
@ -958,7 +958,7 @@ class Data(GpgmeWrapper):
|
||||
if self.wrapped != None and gpgme.gpgme_data_release:
|
||||
gpgme.gpgme_data_release(self.wrapped)
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
self.wrapped = None
|
||||
self._free_datacbs()
|
||||
|
||||
@ -1003,7 +1003,7 @@ class Data(GpgmeWrapper):
|
||||
else:
|
||||
hookdata = (weakref.ref(self),
|
||||
read_cb, write_cb, seek_cb, release_cb)
|
||||
gpgme.pyme_data_new_from_cbs(self, hookdata, tmp)
|
||||
gpgme.gpg_data_new_from_cbs(self, hookdata, tmp)
|
||||
self.wrapped = gpgme.gpgme_data_t_p_value(tmp)
|
||||
gpgme.delete_gpgme_data_t_p(tmp)
|
||||
|
||||
@ -1057,7 +1057,7 @@ class Data(GpgmeWrapper):
|
||||
written = gpgme.gpgme_data_write(self.wrapped, buffer)
|
||||
if written < 0:
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
else:
|
||||
raise GPGMEError.fromSyserror()
|
||||
return written
|
||||
@ -1078,7 +1078,7 @@ class Data(GpgmeWrapper):
|
||||
result = gpgme.gpgme_data_read(self.wrapped, size)
|
||||
except:
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
else:
|
||||
raise
|
||||
return result
|
||||
@ -1089,7 +1089,7 @@ class Data(GpgmeWrapper):
|
||||
result = gpgme.gpgme_data_read(self.wrapped, 4096)
|
||||
except:
|
||||
if self._callback_excinfo:
|
||||
gpgme.pyme_raise_callback_exception(self)
|
||||
gpgme.gpg_raise_callback_exception(self)
|
||||
else:
|
||||
raise
|
||||
if len(result) == 0:
|
@ -28,10 +28,10 @@ EOF = None
|
||||
|
||||
util.process_constants('GPG_ERR_', globals())
|
||||
|
||||
class PymeError(Exception):
|
||||
class GpgError(Exception):
|
||||
pass
|
||||
|
||||
class GPGMEError(PymeError):
|
||||
class GPGMEError(GpgError):
|
||||
def __init__(self, error = None, message = None):
|
||||
self.error = error
|
||||
self.message = message
|
||||
@ -76,7 +76,7 @@ class KeyNotFound(GPGMEError, KeyError):
|
||||
|
||||
# These errors are raised in the idiomatic interface code.
|
||||
|
||||
class EncryptionError(PymeError):
|
||||
class EncryptionError(GpgError):
|
||||
pass
|
||||
|
||||
class InvalidRecipients(EncryptionError):
|
||||
@ -87,7 +87,7 @@ class InvalidRecipients(EncryptionError):
|
||||
gpgme.gpgme_strerror(r.reason))
|
||||
for r in self.recipients)
|
||||
|
||||
class DeryptionError(PymeError):
|
||||
class DeryptionError(GpgError):
|
||||
pass
|
||||
|
||||
class UnsupportedAlgorithm(DeryptionError):
|
||||
@ -96,7 +96,7 @@ class UnsupportedAlgorithm(DeryptionError):
|
||||
def __str__(self):
|
||||
return self.algorithm
|
||||
|
||||
class SigningError(PymeError):
|
||||
class SigningError(GpgError):
|
||||
pass
|
||||
|
||||
class InvalidSigners(SigningError):
|
||||
@ -107,7 +107,7 @@ class InvalidSigners(SigningError):
|
||||
gpgme.gpgme_strerror(s.reason))
|
||||
for s in self.signers)
|
||||
|
||||
class VerificationError(PymeError):
|
||||
class VerificationError(GpgError):
|
||||
pass
|
||||
|
||||
class BadSignatures(VerificationError):
|
@ -21,10 +21,10 @@ del absolute_import, print_function
|
||||
|
||||
from . import gpgme
|
||||
|
||||
productname = 'pyme'
|
||||
productname = 'gpg'
|
||||
versionstr = "@VERSION@"
|
||||
gpgme_versionstr = gpgme.GPGME_VERSION
|
||||
in_tree_build = bool(gpgme.cvar.pyme_in_tree_build)
|
||||
in_tree_build = bool(gpgme.cvar.gpg_in_tree_build)
|
||||
|
||||
versionlist = versionstr.split(".")
|
||||
major = versionlist[0]
|
@ -159,7 +159,7 @@
|
||||
$1 = NULL;
|
||||
else {
|
||||
PyObject *pypointer;
|
||||
pypointer = _pyme_obj2gpgme_data_t($input, $argnum, &wrapper,
|
||||
pypointer = _gpg_obj2gpgme_data_t($input, $argnum, &wrapper,
|
||||
&bytesio, &view);
|
||||
if (pypointer == NULL)
|
||||
return NULL;
|
||||
@ -428,7 +428,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "EncryptResult");
|
||||
$result = _gpg_wrap_result(fragile, "EncryptResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "DecryptResult");
|
||||
$result = _gpg_wrap_result(fragile, "DecryptResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "SignResult");
|
||||
$result = _gpg_wrap_result(fragile, "SignResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "VerifyResult");
|
||||
$result = _gpg_wrap_result(fragile, "VerifyResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "ImportResult");
|
||||
$result = _gpg_wrap_result(fragile, "ImportResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "GenkeyResult");
|
||||
$result = _gpg_wrap_result(fragile, "GenkeyResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -476,7 +476,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "KeylistResult");
|
||||
$result = _gpg_wrap_result(fragile, "KeylistResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@
|
||||
PyObject *fragile;
|
||||
fragile = SWIG_NewPointerObj(SWIG_as_voidptr($1), $1_descriptor,
|
||||
%newpointer_flags);
|
||||
$result = _pyme_wrap_result(fragile, "VFSMountResult");
|
||||
$result = _gpg_wrap_result(fragile, "VFSMountResult");
|
||||
Py_DECREF(fragile);
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@
|
||||
Py_DECREF($result);
|
||||
return NULL; /* raise */
|
||||
}
|
||||
o = _pyme_wrap_result(fragile, "EngineInfo");
|
||||
o = _gpg_wrap_result(fragile, "EngineInfo");
|
||||
Py_DECREF(fragile);
|
||||
if (o == NULL)
|
||||
{
|
||||
@ -528,7 +528,7 @@
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"interact callback must be a tuple of size 2 or 3");
|
||||
|
||||
$1 = (gpgme_interact_cb_t) _pyme_interact_cb;
|
||||
$1 = (gpgme_interact_cb_t) _gpg_interact_cb;
|
||||
$2 = $input;
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@
|
||||
"callback must be a tuple of size 2");
|
||||
if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
|
||||
return PyErr_Format(PyExc_TypeError, "second item must be callable");
|
||||
$1 = _pyme_assuan_data_cb;
|
||||
$1 = _gpg_assuan_data_cb;
|
||||
$2 = $input;
|
||||
}
|
||||
}
|
||||
@ -564,7 +564,7 @@
|
||||
"callback must be a tuple of size 2");
|
||||
if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
|
||||
return PyErr_Format(PyExc_TypeError, "second item must be callable");
|
||||
$1 = _pyme_assuan_inquire_cb;
|
||||
$1 = _gpg_assuan_inquire_cb;
|
||||
$2 = $input;
|
||||
}
|
||||
}
|
||||
@ -581,7 +581,7 @@
|
||||
"callback must be a tuple of size 2");
|
||||
if (! PyCallable_Check(PyTuple_GetItem($input, 1)))
|
||||
return PyErr_Format(PyExc_TypeError, "second item must be callable");
|
||||
$1 = _pyme_assuan_status_cb;
|
||||
$1 = _gpg_assuan_status_cb;
|
||||
$2 = $input;
|
||||
}
|
||||
}
|
||||
@ -654,13 +654,13 @@ FILE *fdopen(int fildes, const char *mode);
|
||||
|
||||
/* SWIG runtime support for helpers.c */
|
||||
PyObject *
|
||||
_pyme_wrap_gpgme_data_t(gpgme_data_t data)
|
||||
_gpg_wrap_gpgme_data_t(gpgme_data_t data)
|
||||
{
|
||||
return SWIG_Python_NewPointerObj(NULL, data, SWIGTYPE_p_gpgme_data, 0);
|
||||
}
|
||||
|
||||
gpgme_ctx_t
|
||||
_pyme_unwrap_gpgme_ctx_t(PyObject *wrapped)
|
||||
_gpg_unwrap_gpgme_ctx_t(PyObject *wrapped)
|
||||
{
|
||||
gpgme_ctx_t result;
|
||||
if (SWIG_ConvertPtr(wrapped,
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "private.h"
|
||||
|
||||
/* Flag specifying whether this is an in-tree build. */
|
||||
int pyme_in_tree_build =
|
||||
int gpg_in_tree_build =
|
||||
#if IN_TREE_BUILD
|
||||
1
|
||||
#else
|
||||
@ -43,7 +43,7 @@ int pyme_in_tree_build =
|
||||
|
||||
static PyObject *GPGMEError = NULL;
|
||||
|
||||
void _pyme_exception_init(void) {
|
||||
void _gpg_exception_init(void) {
|
||||
if (GPGMEError == NULL) {
|
||||
PyObject *errors;
|
||||
PyObject *from_list = PyList_New(0);
|
||||
@ -58,11 +58,11 @@ void _pyme_exception_init(void) {
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_pyme_raise_exception(gpgme_error_t err)
|
||||
_gpg_raise_exception(gpgme_error_t err)
|
||||
{
|
||||
PyObject *e;
|
||||
|
||||
_pyme_exception_init();
|
||||
_gpg_exception_init();
|
||||
if (GPGMEError == NULL)
|
||||
return PyErr_Format(PyExc_RuntimeError, "Got gpgme_error_t %d", err);
|
||||
|
||||
@ -76,7 +76,7 @@ _pyme_raise_exception(gpgme_error_t err)
|
||||
return NULL; /* raise */
|
||||
}
|
||||
|
||||
gpgme_error_t _pyme_exception2code(void) {
|
||||
gpgme_error_t _gpg_exception2code(void) {
|
||||
gpgme_error_t err_status = gpg_error(GPG_ERR_GENERAL);
|
||||
if (GPGMEError && PyErr_ExceptionMatches(GPGMEError)) {
|
||||
PyObject *type = 0, *value = 0, *traceback = 0;
|
||||
@ -94,7 +94,7 @@ gpgme_error_t _pyme_exception2code(void) {
|
||||
/* Exception support for callbacks. */
|
||||
#define EXCINFO "_callback_excinfo"
|
||||
|
||||
static void _pyme_stash_callback_exception(PyObject *weak_self)
|
||||
static void _gpg_stash_callback_exception(PyObject *weak_self)
|
||||
{
|
||||
PyObject *self, *ptype, *pvalue, *ptraceback, *excinfo;
|
||||
|
||||
@ -136,7 +136,7 @@ static void _pyme_stash_callback_exception(PyObject *weak_self)
|
||||
Py_DECREF(excinfo);
|
||||
}
|
||||
|
||||
PyObject *pyme_raise_callback_exception(PyObject *self)
|
||||
PyObject *gpg_raise_callback_exception(PyObject *self)
|
||||
{
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
PyObject *ptype, *pvalue, *ptraceback, *excinfo;
|
||||
@ -192,7 +192,7 @@ PyObject *pyme_raise_callback_exception(PyObject *self)
|
||||
|
||||
/* Convert object to a pointer to gpgme type, generic version. */
|
||||
PyObject *
|
||||
_pyme_obj2gpgme_t(PyObject *input, const char *objtype, int argnum)
|
||||
_gpg_obj2gpgme_t(PyObject *input, const char *objtype, int argnum)
|
||||
{
|
||||
PyObject *pyname = NULL, *pypointer = NULL;
|
||||
pyname = PyObject_GetAttrString(input, "_ctype");
|
||||
@ -229,7 +229,7 @@ _pyme_obj2gpgme_t(PyObject *input, const char *objtype, int argnum)
|
||||
objects with a fileno method, returning it in WRAPPER. This object
|
||||
must be de-referenced when no longer needed. */
|
||||
PyObject *
|
||||
_pyme_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
|
||||
_gpg_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
|
||||
PyObject **bytesio, Py_buffer *view)
|
||||
{
|
||||
gpgme_error_t err;
|
||||
@ -242,9 +242,9 @@ _pyme_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
|
||||
err = gpgme_data_new_from_fd(wrapper, (int) PyLong_AsLong(fd));
|
||||
Py_DECREF(fd);
|
||||
if (err)
|
||||
return _pyme_raise_exception (err);
|
||||
return _gpg_raise_exception (err);
|
||||
|
||||
return _pyme_wrap_gpgme_data_t(*wrapper);
|
||||
return _gpg_wrap_gpgme_data_t(*wrapper);
|
||||
}
|
||||
else
|
||||
PyErr_Clear();
|
||||
@ -283,17 +283,17 @@ _pyme_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
|
||||
|
||||
err = gpgme_data_new_from_mem(wrapper, view->buf, (size_t) view->len, 0);
|
||||
if (err)
|
||||
return _pyme_raise_exception (err);
|
||||
return _gpg_raise_exception (err);
|
||||
|
||||
return _pyme_wrap_gpgme_data_t(*wrapper);
|
||||
return _gpg_wrap_gpgme_data_t(*wrapper);
|
||||
}
|
||||
|
||||
/* As last resort we assume it is a wrapped data object. */
|
||||
if (PyObject_HasAttrString(data, "_ctype"))
|
||||
return _pyme_obj2gpgme_t(data, "gpgme_data_t", argnum);
|
||||
return _gpg_obj2gpgme_t(data, "gpgme_data_t", argnum);
|
||||
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"arg %d: expected pyme.Data, file, or an object "
|
||||
"arg %d: expected gpg.Data, file, or an object "
|
||||
"implementing the buffer protocol, got %s",
|
||||
argnum, data->ob_type->tp_name);
|
||||
}
|
||||
@ -301,7 +301,7 @@ _pyme_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
|
||||
|
||||
|
||||
PyObject *
|
||||
_pyme_wrap_result(PyObject *fragile, const char *classname)
|
||||
_gpg_wrap_result(PyObject *fragile, const char *classname)
|
||||
{
|
||||
static PyObject *results;
|
||||
PyObject *class;
|
||||
@ -348,7 +348,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
||||
PyObject *encoded = NULL;
|
||||
gpgme_error_t err_status = 0;
|
||||
|
||||
_pyme_exception_init();
|
||||
_gpg_exception_init();
|
||||
|
||||
assert (PyTuple_Check(pyhook));
|
||||
assert (PyTuple_Size(pyhook) == 2 || PyTuple_Size(pyhook) == 3);
|
||||
@ -385,12 +385,12 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
||||
retval = PyObject_CallObject(func, args);
|
||||
Py_DECREF(args);
|
||||
if (PyErr_Occurred()) {
|
||||
err_status = _pyme_exception2code();
|
||||
err_status = _gpg_exception2code();
|
||||
} else {
|
||||
if (!retval) {
|
||||
if (write(fd, "\n", 1) < 0) {
|
||||
err_status = gpgme_error_from_syserror ();
|
||||
_pyme_raise_exception (err_status);
|
||||
_gpg_raise_exception (err_status);
|
||||
}
|
||||
} else {
|
||||
char *buf;
|
||||
@ -425,11 +425,11 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
||||
|
||||
if (write(fd, buf, len) < 0) {
|
||||
err_status = gpgme_error_from_syserror ();
|
||||
_pyme_raise_exception (err_status);
|
||||
_gpg_raise_exception (err_status);
|
||||
}
|
||||
if (! err_status && write(fd, "\n", 1) < 0) {
|
||||
err_status = gpgme_error_from_syserror ();
|
||||
_pyme_raise_exception (err_status);
|
||||
_gpg_raise_exception (err_status);
|
||||
}
|
||||
|
||||
Py_DECREF(retval);
|
||||
@ -438,7 +438,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
||||
|
||||
leave:
|
||||
if (err_status)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
|
||||
Py_XDECREF(encoded);
|
||||
PyGILState_Release(state);
|
||||
@ -446,7 +446,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
||||
}
|
||||
|
||||
PyObject *
|
||||
pyme_set_passphrase_cb(PyObject *self, PyObject *cb) {
|
||||
gpg_set_passphrase_cb(PyObject *self, PyObject *cb) {
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
PyObject *wrapped;
|
||||
gpgme_ctx_t ctx;
|
||||
@ -459,7 +459,7 @@ pyme_set_passphrase_cb(PyObject *self, PyObject *cb) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
|
||||
ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
|
||||
Py_DECREF(wrapped);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
@ -512,7 +512,7 @@ static void pyProgressCb(void *hook, const char *what, int type, int current,
|
||||
PyTuple_SetItem(args, 0, PyUnicode_DecodeUTF8(what, strlen (what),
|
||||
"strict"));
|
||||
if (PyErr_Occurred()) {
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
Py_DECREF(args);
|
||||
PyGILState_Release(state);
|
||||
return;
|
||||
@ -527,14 +527,14 @@ static void pyProgressCb(void *hook, const char *what, int type, int current,
|
||||
|
||||
retval = PyObject_CallObject(func, args);
|
||||
if (PyErr_Occurred())
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
Py_DECREF(args);
|
||||
Py_XDECREF(retval);
|
||||
PyGILState_Release(state);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
pyme_set_progress_cb(PyObject *self, PyObject *cb) {
|
||||
gpg_set_progress_cb(PyObject *self, PyObject *cb) {
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
PyObject *wrapped;
|
||||
gpgme_ctx_t ctx;
|
||||
@ -547,7 +547,7 @@ pyme_set_progress_cb(PyObject *self, PyObject *cb) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
|
||||
ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
|
||||
Py_DECREF(wrapped);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
@ -624,19 +624,19 @@ static gpgme_error_t pyStatusCb(void *hook, const char *keyword,
|
||||
|
||||
retval = PyObject_CallObject(func, pyargs);
|
||||
if (PyErr_Occurred())
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
Py_DECREF(pyargs);
|
||||
Py_XDECREF(retval);
|
||||
|
||||
leave:
|
||||
if (err)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
PyGILState_Release(state);
|
||||
return err;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
pyme_set_status_cb(PyObject *self, PyObject *cb) {
|
||||
gpg_set_status_cb(PyObject *self, PyObject *cb) {
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
PyObject *wrapped;
|
||||
gpgme_ctx_t ctx;
|
||||
@ -649,7 +649,7 @@ pyme_set_status_cb(PyObject *self, PyObject *cb) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx = _pyme_unwrap_gpgme_ctx_t(wrapped);
|
||||
ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
|
||||
Py_DECREF(wrapped);
|
||||
if (ctx == NULL)
|
||||
{
|
||||
@ -684,7 +684,7 @@ pyme_set_status_cb(PyObject *self, PyObject *cb) {
|
||||
|
||||
/* Interact callbacks. */
|
||||
gpgme_error_t
|
||||
_pyme_interact_cb(void *opaque, const char *keyword,
|
||||
_gpg_interact_cb(void *opaque, const char *keyword,
|
||||
const char *args, int fd)
|
||||
{
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
@ -694,7 +694,7 @@ _pyme_interact_cb(void *opaque, const char *keyword,
|
||||
gpgme_error_t err_status = 0;
|
||||
PyObject *self = NULL;
|
||||
|
||||
_pyme_exception_init();
|
||||
_gpg_exception_init();
|
||||
|
||||
assert (PyTuple_Check(pyopaque));
|
||||
assert (PyTuple_Size(pyopaque) == 2 || PyTuple_Size(pyopaque) == 3);
|
||||
@ -725,7 +725,7 @@ _pyme_interact_cb(void *opaque, const char *keyword,
|
||||
retval = PyObject_CallObject(func, pyargs);
|
||||
Py_DECREF(pyargs);
|
||||
if (PyErr_Occurred()) {
|
||||
err_status = _pyme_exception2code();
|
||||
err_status = _gpg_exception2code();
|
||||
} else {
|
||||
if (fd>=0 && retval && PyUnicode_Check(retval)) {
|
||||
PyObject *encoded = NULL;
|
||||
@ -747,18 +747,18 @@ _pyme_interact_cb(void *opaque, const char *keyword,
|
||||
|
||||
if (write(fd, buffer, size) < 0) {
|
||||
err_status = gpgme_error_from_syserror ();
|
||||
_pyme_raise_exception (err_status);
|
||||
_gpg_raise_exception (err_status);
|
||||
}
|
||||
if (! err_status && write(fd, "\n", 1) < 0) {
|
||||
err_status = gpgme_error_from_syserror ();
|
||||
_pyme_raise_exception (err_status);
|
||||
_gpg_raise_exception (err_status);
|
||||
}
|
||||
Py_DECREF(encoded);
|
||||
}
|
||||
}
|
||||
leave:
|
||||
if (err_status)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
|
||||
Py_XDECREF(retval);
|
||||
PyGILState_Release(state);
|
||||
@ -804,7 +804,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
|
||||
retval = PyObject_CallObject(func, pyargs);
|
||||
Py_DECREF(pyargs);
|
||||
if (PyErr_Occurred()) {
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
goto leave;
|
||||
}
|
||||
@ -813,7 +813,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected bytes from read callback, got %s",
|
||||
retval->ob_type->tp_name);
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
goto leave;
|
||||
}
|
||||
@ -822,7 +822,7 @@ static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %zu bytes from read callback, got %zu",
|
||||
size, PyBytes_Size(retval));
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
goto leave;
|
||||
}
|
||||
@ -871,7 +871,7 @@ static ssize_t pyDataWriteCb(void *hook, const void *buffer, size_t size)
|
||||
retval = PyObject_CallObject(func, pyargs);
|
||||
Py_DECREF(pyargs);
|
||||
if (PyErr_Occurred()) {
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
goto leave;
|
||||
}
|
||||
@ -887,7 +887,7 @@ static ssize_t pyDataWriteCb(void *hook, const void *buffer, size_t size)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected int from write callback, got %s",
|
||||
retval->ob_type->tp_name);
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@ -938,7 +938,7 @@ static off_t pyDataSeekCb(void *hook, off_t offset, int whence)
|
||||
retval = PyObject_CallObject(func, pyargs);
|
||||
Py_DECREF(pyargs);
|
||||
if (PyErr_Occurred()) {
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
goto leave;
|
||||
}
|
||||
@ -958,7 +958,7 @@ static off_t pyDataSeekCb(void *hook, off_t offset, int whence)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected int from seek callback, got %s",
|
||||
retval->ob_type->tp_name);
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@ -1000,12 +1000,12 @@ static void pyDataReleaseCb(void *hook)
|
||||
Py_XDECREF(retval);
|
||||
Py_DECREF(pyargs);
|
||||
if (PyErr_Occurred())
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
PyGILState_Release(state);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
pyme_data_new_from_cbs(PyObject *self,
|
||||
gpg_data_new_from_cbs(PyObject *self,
|
||||
PyObject *pycbs,
|
||||
gpgme_data_t *r_data)
|
||||
{
|
||||
@ -1026,7 +1026,7 @@ pyme_data_new_from_cbs(PyObject *self,
|
||||
|
||||
err = gpgme_data_new_from_cbs(r_data, &cbs, (void *) pycbs);
|
||||
if (err)
|
||||
return _pyme_raise_exception(err);
|
||||
return _gpg_raise_exception(err);
|
||||
|
||||
PyObject_SetAttrString(self, "_data_cbs", pycbs);
|
||||
|
||||
@ -1040,7 +1040,7 @@ pyme_data_new_from_cbs(PyObject *self,
|
||||
/* The assuan callbacks. */
|
||||
|
||||
gpgme_error_t
|
||||
_pyme_assuan_data_cb (void *hook, const void *data, size_t datalen)
|
||||
_gpg_assuan_data_cb (void *hook, const void *data, size_t datalen)
|
||||
{
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
gpgme_error_t err = 0;
|
||||
@ -1059,25 +1059,25 @@ _pyme_assuan_data_cb (void *hook, const void *data, size_t datalen)
|
||||
py_data = PyBytes_FromStringAndSize(data, datalen);
|
||||
if (py_data == NULL)
|
||||
{
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
retval = PyObject_CallFunctionObjArgs(func, py_data, NULL);
|
||||
if (PyErr_Occurred())
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
Py_DECREF(py_data);
|
||||
Py_XDECREF(retval);
|
||||
|
||||
leave:
|
||||
if (err)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
PyGILState_Release(state);
|
||||
return err;
|
||||
}
|
||||
|
||||
gpgme_error_t
|
||||
_pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
|
||||
_gpg_assuan_inquire_cb (void *hook, const char *name, const char *args,
|
||||
gpgme_data_t *r_data)
|
||||
{
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
@ -1098,20 +1098,20 @@ _pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
|
||||
py_name = PyUnicode_FromString(name);
|
||||
if (py_name == NULL)
|
||||
{
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
py_args = PyUnicode_FromString(args);
|
||||
if (py_args == NULL)
|
||||
{
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
retval = PyObject_CallFunctionObjArgs(func, py_name, py_args, NULL);
|
||||
if (PyErr_Occurred())
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
Py_XDECREF(retval);
|
||||
|
||||
/* FIXME: Returning data is not yet implemented. */
|
||||
@ -1121,13 +1121,13 @@ _pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
|
||||
Py_XDECREF(py_name);
|
||||
Py_XDECREF(py_args);
|
||||
if (err)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
PyGILState_Release(state);
|
||||
return err;
|
||||
}
|
||||
|
||||
gpgme_error_t
|
||||
_pyme_assuan_status_cb (void *hook, const char *status, const char *args)
|
||||
_gpg_assuan_status_cb (void *hook, const char *status, const char *args)
|
||||
{
|
||||
PyGILState_STATE state = PyGILState_Ensure();
|
||||
gpgme_error_t err = 0;
|
||||
@ -1147,27 +1147,27 @@ _pyme_assuan_status_cb (void *hook, const char *status, const char *args)
|
||||
py_status = PyUnicode_FromString(status);
|
||||
if (py_status == NULL)
|
||||
{
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
py_args = PyUnicode_FromString(args);
|
||||
if (py_args == NULL)
|
||||
{
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
retval = PyObject_CallFunctionObjArgs(func, py_status, py_args, NULL);
|
||||
if (PyErr_Occurred())
|
||||
err = _pyme_exception2code();
|
||||
err = _gpg_exception2code();
|
||||
Py_XDECREF(retval);
|
||||
|
||||
leave:
|
||||
Py_XDECREF(py_status);
|
||||
Py_XDECREF(py_args);
|
||||
if (err)
|
||||
_pyme_stash_callback_exception(self);
|
||||
_gpg_stash_callback_exception(self);
|
||||
PyGILState_Release(state);
|
||||
return err;
|
||||
}
|
||||
|
@ -31,13 +31,13 @@
|
||||
#endif
|
||||
|
||||
/* Flag specifying whether this is an in-tree build. */
|
||||
extern int pyme_in_tree_build;
|
||||
extern int gpg_in_tree_build;
|
||||
|
||||
PyObject *pyme_raise_callback_exception(PyObject *self);
|
||||
PyObject *gpg_raise_callback_exception(PyObject *self);
|
||||
|
||||
PyObject *pyme_set_passphrase_cb(PyObject *self, PyObject *cb);
|
||||
PyObject *pyme_set_progress_cb(PyObject *self, PyObject *cb);
|
||||
PyObject *pyme_set_status_cb(PyObject *self, PyObject *cb);
|
||||
PyObject *gpg_set_passphrase_cb(PyObject *self, PyObject *cb);
|
||||
PyObject *gpg_set_progress_cb(PyObject *self, PyObject *cb);
|
||||
PyObject *gpg_set_status_cb(PyObject *self, PyObject *cb);
|
||||
|
||||
PyObject *pyme_data_new_from_cbs(PyObject *self, PyObject *pycbs,
|
||||
PyObject *gpg_data_new_from_cbs(PyObject *self, PyObject *pycbs,
|
||||
gpgme_data_t *r_data);
|
||||
|
@ -19,36 +19,36 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#ifndef _PYME_PRIVATE_H_
|
||||
#define _PYME_PRIVATE_H_
|
||||
#ifndef _GPG_PRIVATE_H_
|
||||
#define _GPG_PRIVATE_H_
|
||||
|
||||
/* GPGME glue. Implemented in helpers.c. */
|
||||
|
||||
void _pyme_exception_init(void);
|
||||
gpgme_error_t _pyme_exception2code(void);
|
||||
void _gpg_exception_init(void);
|
||||
gpgme_error_t _gpg_exception2code(void);
|
||||
|
||||
PyObject *_pyme_obj2gpgme_t(PyObject *input, const char *objtype, int argnum);
|
||||
PyObject *_pyme_obj2gpgme_data_t(PyObject *input, int argnum,
|
||||
PyObject *_gpg_obj2gpgme_t(PyObject *input, const char *objtype, int argnum);
|
||||
PyObject *_gpg_obj2gpgme_data_t(PyObject *input, int argnum,
|
||||
gpgme_data_t *wrapper,
|
||||
PyObject **bytesio, Py_buffer *view);
|
||||
|
||||
PyObject *_pyme_wrap_result(PyObject *fragile, const char *classname);
|
||||
PyObject *_gpg_wrap_result(PyObject *fragile, const char *classname);
|
||||
|
||||
gpgme_error_t _pyme_interact_cb(void *opaque, const char *keyword,
|
||||
gpgme_error_t _gpg_interact_cb(void *opaque, const char *keyword,
|
||||
const char *args, int fd);
|
||||
gpgme_error_t _pyme_assuan_data_cb (void *hook,
|
||||
gpgme_error_t _gpg_assuan_data_cb (void *hook,
|
||||
const void *data, size_t datalen);
|
||||
gpgme_error_t _pyme_assuan_inquire_cb (void *hook,
|
||||
gpgme_error_t _gpg_assuan_inquire_cb (void *hook,
|
||||
const char *name, const char *args,
|
||||
gpgme_data_t *r_data);
|
||||
gpgme_error_t _pyme_assuan_status_cb (void *hook,
|
||||
gpgme_error_t _gpg_assuan_status_cb (void *hook,
|
||||
const char *status, const char *args);
|
||||
|
||||
|
||||
|
||||
/* SWIG runtime support. Implemented in gpgme.i. */
|
||||
|
||||
PyObject *_pyme_wrap_gpgme_data_t(gpgme_data_t data);
|
||||
gpgme_ctx_t _pyme_unwrap_gpgme_ctx_t(PyObject *wrapped);
|
||||
PyObject *_gpg_wrap_gpgme_data_t(gpgme_data_t data);
|
||||
gpgme_ctx_t _gpg_unwrap_gpgme_ctx_t(PyObject *wrapped);
|
||||
|
||||
#endif /* _PYME_PRIVATE_H_ */
|
||||
#endif /* _GPG_PRIVATE_H_ */
|
||||
|
@ -23,7 +23,7 @@ import os, os.path, sys
|
||||
import glob
|
||||
import subprocess
|
||||
|
||||
# Out-of-tree build of the pyme3 bindings.
|
||||
# Out-of-tree build of the gpg bindings.
|
||||
gpg_error_config = ["gpg-error-config"]
|
||||
gpgme_config_flags = ["--thread=pthread"]
|
||||
gpgme_config = ["gpgme-config"] + gpgme_config_flags
|
||||
@ -88,7 +88,7 @@ if not os.path.exists(gpg_error_h):
|
||||
glob.glob(os.path.join(gpg_error_prefix, "include",
|
||||
"*", "gpg-error.h"))[0]
|
||||
|
||||
print("Building pyme3 using {} and {}.".format(gpgme_h, gpg_error_h))
|
||||
print("Building python gpg module using {} and {}.".format(gpgme_h, gpg_error_h))
|
||||
|
||||
# Cleanup gpgme.h from deprecated functions and typedefs.
|
||||
subprocess.check_call([sys.executable, "gpgme-h-clean.py", gpgme_h],
|
||||
@ -152,15 +152,15 @@ class BuildExtFirstHack(build):
|
||||
self.run_command('build_ext')
|
||||
build.run(self)
|
||||
|
||||
swige = Extension("pyme._gpgme", ["gpgme.i", "helpers.c"],
|
||||
swige = Extension("gpg._gpgme", ["gpgme.i", "helpers.c"],
|
||||
swig_opts = ['-py3', '-builtin', '-threads',
|
||||
'-outdir', 'pyme'] + extra_swig_opts,
|
||||
'-outdir', 'gpg'] + extra_swig_opts,
|
||||
include_dirs = include_dirs,
|
||||
define_macros = define_macros,
|
||||
library_dirs = library_dirs,
|
||||
extra_link_args = libs)
|
||||
|
||||
setup(name="pyme3",
|
||||
setup(name="gpg",
|
||||
cmdclass={'build': BuildExtFirstHack},
|
||||
version="@VERSION@",
|
||||
description='Python bindings for GPGME GnuPG cryptography library',
|
||||
@ -170,8 +170,8 @@ setup(name="pyme3",
|
||||
author_email='gnupg-devel@gnupg.org',
|
||||
url='https://www.gnupg.org',
|
||||
ext_modules=[swige],
|
||||
packages = ['pyme', 'pyme.constants', 'pyme.constants.data',
|
||||
'pyme.constants.keylist', 'pyme.constants.sig'],
|
||||
packages = ['gpg', 'gpg.constants', 'gpg.constants.data',
|
||||
'gpg.constants.keylist', 'gpg.constants.sig'],
|
||||
license="LGPL2.1+ (the library), GPL2+ (tests and examples)",
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
|
@ -22,14 +22,14 @@ del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import pyme
|
||||
import gpg
|
||||
import support
|
||||
support.init_gpgme(pyme.constants.PROTOCOL_OpenPGP)
|
||||
support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP)
|
||||
|
||||
subprocess.check_call([os.path.join(os.getenv('top_srcdir'),
|
||||
"tests", "start-stop-agent"), "--start"])
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
alpha = c.get_key("A0FF4590BB6122EDEF6E3C542D727CC768697734", False)
|
||||
bob = c.get_key("D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", False)
|
||||
|
||||
|
@ -20,7 +20,7 @@ del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pyme import core
|
||||
from gpg import core
|
||||
|
||||
# known keys
|
||||
alpha = "A0FF4590BB6122EDEF6E3C542D727CC768697734"
|
||||
|
@ -21,7 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -87,7 +87,7 @@ Key-Type: RSA
|
||||
Key-Length: 1024
|
||||
Name-Real: Joe Tester
|
||||
Name-Comment: with stupid passphrase
|
||||
Name-Email: joe+pyme@example.org
|
||||
Name-Email: joe+gpg@example.org
|
||||
Passphrase: Crypt0R0cks
|
||||
Expire-Date: 2020-12-31
|
||||
</GnupgKeyParms>
|
||||
|
@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
from pyme import core
|
||||
from gpg import core
|
||||
|
||||
data = core.Data('Hello world!')
|
||||
assert data.read() == b'Hello world!'
|
||||
|
@ -20,8 +20,8 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
from pyme import core, constants, errors
|
||||
import gpg
|
||||
from gpg import core, constants, errors
|
||||
import support
|
||||
|
||||
def check_verify_result(result, summary, fpr, status):
|
||||
@ -55,7 +55,7 @@ check_verify_result(verify_result,
|
||||
errors.NO_ERROR)
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
alpha = c.get_key("A0FF4590BB6122EDEF6E3C542D727CC768697734", False)
|
||||
bob = c.get_key("D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", False)
|
||||
plaintext, _, verify_result = \
|
||||
|
@ -20,8 +20,8 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -38,7 +38,7 @@ assert not result.unsupported_algorithm, \
|
||||
support.print_data(sink)
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
plaintext, _, _ = c.decrypt(open(support.make_filename("cipher-1.asc")))
|
||||
assert len(plaintext) > 0
|
||||
assert plaintext.find(b'Wenn Sie dies lesen k') >= 0, \
|
||||
|
@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
class KeyEditor(object):
|
||||
|
@ -22,7 +22,7 @@ del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import random
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
|
@ -21,8 +21,8 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -76,7 +76,7 @@ for recipients in (keys, []):
|
||||
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
message = "Hallo Leute\n".encode()
|
||||
ciphertext, _, sig_result = c.encrypt(message,
|
||||
recipients=keys,
|
||||
@ -91,7 +91,7 @@ with pyme.Context(armor=True) as c:
|
||||
c.signers = [c.get_key(support.encrypt_only, True)]
|
||||
try:
|
||||
c.encrypt(message, recipients=keys, always_trust=True)
|
||||
except pyme.errors.InvalidSigners as e:
|
||||
except gpg.errors.InvalidSigners as e:
|
||||
assert len(e.signers) == 1
|
||||
assert support.encrypt_only.endswith(e.signers[0].fpr)
|
||||
else:
|
||||
|
@ -21,8 +21,8 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -68,7 +68,7 @@ for passphrase in ("abc", b"abc"):
|
||||
|
||||
# Idiomatic interface.
|
||||
for passphrase in ("abc", b"abc"):
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
# Check that the passphrase callback is not altered.
|
||||
def f(*args):
|
||||
assert False
|
||||
|
@ -20,8 +20,8 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -42,7 +42,7 @@ assert not result.invalid_recipients, \
|
||||
support.print_data(sink)
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
ciphertext, _, _ = c.encrypt("Hallo Leute\n".encode(),
|
||||
recipients=keys,
|
||||
sign=False,
|
||||
@ -58,7 +58,7 @@ with pyme.Context(armor=True) as c:
|
||||
c.encrypt("Hallo Leute\n".encode(),
|
||||
recipients=[c.get_key(support.sign_only, False)],
|
||||
sign=False, always_trust=True)
|
||||
except pyme.errors.InvalidRecipients as e:
|
||||
except gpg.errors.InvalidRecipients as e:
|
||||
assert len(e.recipients) == 1
|
||||
assert support.sign_only.endswith(e.recipients[0].fpr)
|
||||
else:
|
||||
|
@ -20,7 +20,7 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
|
@ -21,7 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
testname = "abcde12345"
|
||||
|
@ -24,13 +24,13 @@ import sys
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
import pyme
|
||||
import gpg
|
||||
import support
|
||||
|
||||
support.init_gpgme(pyme.constants.PROTOCOL_OpenPGP)
|
||||
support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP)
|
||||
|
||||
# Both Context and Data can be used as context manager:
|
||||
with pyme.Context() as c, pyme.Data() as d:
|
||||
with gpg.Context() as c, gpg.Data() as d:
|
||||
c.get_engine_info()
|
||||
d.write(b"Halloechen")
|
||||
leak_c = c
|
||||
@ -39,17 +39,17 @@ assert leak_c.wrapped == None
|
||||
assert leak_d.wrapped == None
|
||||
|
||||
def sign_and_verify(source, signed, sink):
|
||||
with pyme.Context() as c:
|
||||
c.op_sign(source, signed, pyme.constants.SIG_MODE_NORMAL)
|
||||
with gpg.Context() as c:
|
||||
c.op_sign(source, signed, gpg.constants.SIG_MODE_NORMAL)
|
||||
signed.seek(0, os.SEEK_SET)
|
||||
c.op_verify(signed, None, sink)
|
||||
result = c.op_verify_result()
|
||||
|
||||
assert len(result.signatures) == 1, "Unexpected number of signatures"
|
||||
sig = result.signatures[0]
|
||||
assert sig.summary == (pyme.constants.SIGSUM_VALID |
|
||||
pyme.constants.SIGSUM_GREEN)
|
||||
assert pyme.errors.GPGMEError(sig.status).getcode() == pyme.errors.NO_ERROR
|
||||
assert sig.summary == (gpg.constants.SIGSUM_VALID |
|
||||
gpg.constants.SIGSUM_GREEN)
|
||||
assert gpg.errors.GPGMEError(sig.status).getcode() == gpg.errors.NO_ERROR
|
||||
|
||||
sink.seek(0, os.SEEK_SET)
|
||||
assert sink.read() == b"Hallo Leute\n"
|
||||
@ -80,5 +80,5 @@ if sys.version_info[0] == 3:
|
||||
|
||||
# Demonstrate automatic wrapping of objects implementing the buffer
|
||||
# interface, and the use of data objects with the 'with' statement.
|
||||
with io.BytesIO(preallocate) as signed, pyme.Data() as sink:
|
||||
with io.BytesIO(preallocate) as signed, gpg.Data() as sink:
|
||||
sign_and_verify(b"Hallo Leute\n", signed, sink)
|
||||
|
@ -20,7 +20,7 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
def check_result(result, fpr, secret):
|
||||
|
@ -20,8 +20,8 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
@ -248,7 +248,7 @@ for i, key in enumerate(c.keylist()):
|
||||
|
||||
|
||||
# check get_key()
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
c.get_key(support.alpha)
|
||||
c.get_key(support.alpha, secret=True)
|
||||
|
||||
@ -263,7 +263,7 @@ with pyme.Context() as c:
|
||||
# Legacy error
|
||||
try:
|
||||
c.get_key(support.no_such_key)
|
||||
except pyme.errors.GPGMEError:
|
||||
except gpg.errors.GPGMEError:
|
||||
pass
|
||||
else:
|
||||
assert False, "Expected GPGMEError"
|
||||
|
@ -20,17 +20,17 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
import gpg
|
||||
|
||||
with pyme.Context(protocol=pyme.constants.PROTOCOL_ASSUAN) as c:
|
||||
with gpg.Context(protocol=gpg.constants.PROTOCOL_ASSUAN) as c:
|
||||
# Do nothing.
|
||||
c.assuan_transact('nop')
|
||||
c.assuan_transact('NOP')
|
||||
c.assuan_transact(['NOP'])
|
||||
|
||||
err = c.assuan_transact('idontexist')
|
||||
assert err.getsource() == pyme.errors.SOURCE_GPGAGENT
|
||||
assert err.getcode() == pyme.errors.ASS_UNKNOWN_CMD
|
||||
assert err.getsource() == gpg.errors.SOURCE_GPGAGENT
|
||||
assert err.getcode() == gpg.errors.ASS_UNKNOWN_CMD
|
||||
|
||||
# Invoke the pinentry to get a confirmation.
|
||||
c.assuan_transact(['GET_CONFIRMATION', 'Hello there'])
|
||||
|
@ -21,7 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
expected_notations = {
|
||||
|
@ -21,8 +21,8 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
def fail(msg):
|
||||
@ -90,23 +90,23 @@ check_result(result, constants.SIG_MODE_CLEAR)
|
||||
support.print_data(sink)
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context(armor=True, textmode=True) as c:
|
||||
with gpg.Context(armor=True, textmode=True) as c:
|
||||
message = "Hallo Leute\n".encode()
|
||||
signed, _ = c.sign(message)
|
||||
assert len(signed) > 0
|
||||
assert signed.find(b'BEGIN PGP MESSAGE') > 0, 'Message not found'
|
||||
|
||||
signed, _ = c.sign(message, mode=pyme.constants.SIG_MODE_DETACH)
|
||||
signed, _ = c.sign(message, mode=gpg.constants.SIG_MODE_DETACH)
|
||||
assert len(signed) > 0
|
||||
assert signed.find(b'BEGIN PGP SIGNATURE') > 0, 'Signature not found'
|
||||
|
||||
signed, _ = c.sign(message, mode=pyme.constants.SIG_MODE_CLEAR)
|
||||
signed, _ = c.sign(message, mode=gpg.constants.SIG_MODE_CLEAR)
|
||||
assert len(signed) > 0
|
||||
assert signed.find(b'BEGIN PGP SIGNED MESSAGE') > 0, 'Message not found'
|
||||
assert signed.find(message) > 0, 'Message content not found'
|
||||
assert signed.find(b'BEGIN PGP SIGNATURE') > 0, 'Signature not found'
|
||||
|
||||
with pyme.Context() as c:
|
||||
with gpg.Context() as c:
|
||||
message = "Hallo Leute\n".encode()
|
||||
|
||||
c.signers = [c.get_key(support.sign_only, True)]
|
||||
@ -115,7 +115,7 @@ with pyme.Context() as c:
|
||||
c.signers = [c.get_key(support.encrypt_only, True)]
|
||||
try:
|
||||
c.sign(message)
|
||||
except pyme.errors.InvalidSigners as e:
|
||||
except gpg.errors.InvalidSigners as e:
|
||||
assert len(e.signers) == 1
|
||||
assert support.encrypt_only.endswith(e.signers[0].fpr)
|
||||
else:
|
||||
|
@ -20,8 +20,8 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import pyme
|
||||
from pyme import core, constants
|
||||
import gpg
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
def fail(msg):
|
||||
@ -81,7 +81,7 @@ for mode in (constants.SIG_MODE_NORMAL, constants.SIG_MODE_DETACH,
|
||||
support.print_data(sink)
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context(armor=True, textmode=True, signers=keys) as c:
|
||||
with gpg.Context(armor=True, textmode=True, signers=keys) as c:
|
||||
message = "Hallo Leute\n".encode()
|
||||
signed, result = c.sign(message)
|
||||
check_result(result, constants.SIG_MODE_NORMAL)
|
||||
|
@ -20,7 +20,7 @@
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
from pyme import core, constants
|
||||
from gpg import core, constants
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
|
@ -22,8 +22,8 @@ del absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pyme
|
||||
from pyme import core, constants, errors
|
||||
import gpg
|
||||
from gpg import core, constants, errors
|
||||
import support
|
||||
|
||||
test_text1 = b"Just GNU it!\n"
|
||||
@ -145,7 +145,7 @@ else:
|
||||
|
||||
|
||||
# Idiomatic interface.
|
||||
with pyme.Context(armor=True) as c:
|
||||
with gpg.Context(armor=True) as c:
|
||||
# Checking a valid message.
|
||||
_, result = c.verify(test_text1, test_sig1)
|
||||
check_result(result, constants.SIGSUM_VALID | constants.SIGSUM_GREEN,
|
||||
|
@ -21,7 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
del absolute_import, print_function, unicode_literals
|
||||
|
||||
import time
|
||||
from pyme import core, constants, errors
|
||||
from gpg import core, constants, errors
|
||||
import support
|
||||
|
||||
support.init_gpgme(constants.PROTOCOL_OpenPGP)
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyme import core
|
||||
from gpg import core
|
||||
|
||||
d0 = core.Data()
|
||||
d0.seek # trigger on-demand-wrapping
|
||||
|
Loading…
Reference in New Issue
Block a user