diff options
Diffstat (limited to '')
25 files changed, 103 insertions, 78 deletions
| diff --git a/lang/python/examples/assuan.py b/lang/python/examples/assuan.py index f02cd166..dd42ad40 100644 --- a/lang/python/examples/assuan.py +++ b/lang/python/examples/assuan.py @@ -22,7 +22,7 @@ del absolute_import, print_function, unicode_literals  import gpg -with gpg.Context(protocol=gpg.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")) diff --git a/lang/python/examples/testCMSgetkey.py b/lang/python/examples/testCMSgetkey.py index 0f02cb1b..d4c08840 100644 --- a/lang/python/examples/testCMSgetkey.py +++ b/lang/python/examples/testCMSgetkey.py @@ -27,7 +27,7 @@ import gpg  if len(sys.argv) != 2:      sys.exit("fingerprint or unique key ID for gpgme_get_key()") -with gpg.Context(protocol=gpg.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) diff --git a/lang/python/gpg/constants/sig/__init__.py b/lang/python/gpg/constants/sig/__init__.py index 2ce0edfd..39d4e6e1 100644 --- a/lang/python/gpg/constants/sig/__init__.py +++ b/lang/python/gpg/constants/sig/__init__.py @@ -2,5 +2,5 @@  from __future__ import absolute_import, print_function, unicode_literals  del absolute_import, print_function, unicode_literals -from . import mode -__all__ = ['mode'] +from . import mode, notation +__all__ = ['mode', 'notation'] diff --git a/lang/python/gpg/constants/sig/notation.py b/lang/python/gpg/constants/sig/notation.py new file mode 100644 index 00000000..9a79e014 --- /dev/null +++ b/lang/python/gpg/constants/sig/notation.py @@ -0,0 +1,25 @@ +# Constants for signature notation data. +# +# Copyright (C) 2016 g10 Code GmbH +# +# This file is part of GPGME. +# +# GPGME is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# GPGME is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General +# Public License for more details. +# +# 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 __future__ import absolute_import, print_function, unicode_literals +del absolute_import, print_function, unicode_literals + +from gpg import util +util.process_constants('GPGME_SIG_NOTATION_', globals()) +del util diff --git a/lang/python/tests/initial.py b/lang/python/tests/initial.py index a811a936..ebe7f8ad 100755 --- a/lang/python/tests/initial.py +++ b/lang/python/tests/initial.py @@ -24,7 +24,7 @@ import os  import subprocess  import gpg  import support -support.init_gpgme(gpg.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"]) diff --git a/lang/python/tests/t-callbacks.py b/lang/python/tests/t-callbacks.py index 05eb194b..eed50bc4 100755 --- a/lang/python/tests/t-callbacks.py +++ b/lang/python/tests/t-callbacks.py @@ -24,7 +24,7 @@ import os  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_pinentry_mode(gpg.constants.PINENTRY_MODE_LOOPBACK) diff --git a/lang/python/tests/t-decrypt-verify.py b/lang/python/tests/t-decrypt-verify.py index 1fa7a6f0..62431671 100755 --- a/lang/python/tests/t-decrypt-verify.py +++ b/lang/python/tests/t-decrypt-verify.py @@ -31,10 +31,10 @@ def check_verify_result(result, summary, fpr, status):      assert gpg.errors.GPGMEError(sig.status).getcode() == status      assert len(sig.notations) == 0      assert not sig.wrong_key_usage -    assert sig.validity == gpg.constants.VALIDITY_FULL +    assert sig.validity == gpg.constants.validity.FULL      assert gpg.errors.GPGMEError(sig.validity_reason).getcode() == gpg.errors.NO_ERROR -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  source = gpg.Data(file=support.make_filename("cipher-2.asc")) @@ -49,7 +49,7 @@ support.print_data(sink)  verify_result = c.op_verify_result()  check_verify_result(verify_result, -                    gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, +                    gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN,                      "A0FF4590BB6122EDEF6E3C542D727CC768697734",                      gpg.errors.NO_ERROR) @@ -62,7 +62,7 @@ with gpg.Context() as c:      assert plaintext.find(b'Wenn Sie dies lesen k') >= 0, \          'Plaintext not found'      check_verify_result(verify_result, -                        gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, +                        gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN,                          "A0FF4590BB6122EDEF6E3C542D727CC768697734",                          gpg.errors.NO_ERROR) diff --git a/lang/python/tests/t-decrypt.py b/lang/python/tests/t-decrypt.py index daaad3d2..1af05626 100755 --- a/lang/python/tests/t-decrypt.py +++ b/lang/python/tests/t-decrypt.py @@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  source = gpg.Data(file=support.make_filename("cipher-1.asc")) diff --git a/lang/python/tests/t-edit.py b/lang/python/tests/t-edit.py index 82f64019..bd70e7ee 100755 --- a/lang/python/tests/t-edit.py +++ b/lang/python/tests/t-edit.py @@ -51,7 +51,7 @@ class KeyEditor(object):          return result -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_pinentry_mode(gpg.constants.PINENTRY_MODE_LOOPBACK) diff --git a/lang/python/tests/t-encrypt-large.py b/lang/python/tests/t-encrypt-large.py index 1c3c4f61..cdb4a32a 100755 --- a/lang/python/tests/t-encrypt-large.py +++ b/lang/python/tests/t-encrypt-large.py @@ -30,7 +30,7 @@ if len(sys.argv) == 2:  else:      nbytes = 100000 -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  ntoread = nbytes diff --git a/lang/python/tests/t-encrypt-sign.py b/lang/python/tests/t-encrypt-sign.py index 9b062026..094a2b00 100755 --- a/lang/python/tests/t-encrypt-sign.py +++ b/lang/python/tests/t-encrypt-sign.py @@ -24,7 +24,7 @@ import sys  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) @@ -39,11 +39,11 @@ def check_result(r, typ):      if signature.type != typ:          sys.exit("Wrong type of signature created") -    if signature.pubkey_algo != gpg.constants.PK_DSA: +    if signature.pubkey_algo != gpg.constants.pk.DSA:          sys.exit("Wrong pubkey algorithm reported: {}".format(              signature.pubkey_algo)) -    if signature.hash_algo not in (gpg.constants.MD_SHA1, gpg.constants.MD_RMD160): +    if signature.hash_algo not in (gpg.constants.md.SHA1, gpg.constants.md.RMD160):          sys.exit("Wrong hash algorithm reported: {}".format(              signature.hash_algo)) @@ -69,7 +69,7 @@ for recipients in (keys, []):              result.invalid_recipients.fpr)      result = c.op_sign_result() -    check_result(result, gpg.constants.SIG_MODE_NORMAL) +    check_result(result, gpg.constants.sig.mode.NORMAL)      support.print_data(sink) @@ -82,7 +82,7 @@ with gpg.Context(armor=True) as c:                                            always_trust=True)      assert len(ciphertext) > 0      assert ciphertext.find(b'BEGIN PGP MESSAGE') > 0, 'Marker not found' -    check_result(sig_result, gpg.constants.SIG_MODE_NORMAL) +    check_result(sig_result, gpg.constants.sig.mode.NORMAL)      c.signers = [c.get_key(support.sign_only, True)]      c.encrypt(message, recipients=keys, always_trust=True) diff --git a/lang/python/tests/t-encrypt-sym.py b/lang/python/tests/t-encrypt-sym.py index 3990556d..07e6b62c 100755 --- a/lang/python/tests/t-encrypt-sym.py +++ b/lang/python/tests/t-encrypt-sym.py @@ -24,7 +24,7 @@ import os  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  for passphrase in ("abc", b"abc"):      c = gpg.Context() diff --git a/lang/python/tests/t-encrypt.py b/lang/python/tests/t-encrypt.py index eaa454ff..0c0ca357 100755 --- a/lang/python/tests/t-encrypt.py +++ b/lang/python/tests/t-encrypt.py @@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) diff --git a/lang/python/tests/t-export.py b/lang/python/tests/t-export.py index 4f67502e..4927beb0 100755 --- a/lang/python/tests/t-export.py +++ b/lang/python/tests/t-export.py @@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) diff --git a/lang/python/tests/t-file-name.py b/lang/python/tests/t-file-name.py index 37cd2619..d12afb86 100755 --- a/lang/python/tests/t-file-name.py +++ b/lang/python/tests/t-file-name.py @@ -26,7 +26,7 @@ import support  testname = "abcde12345" -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) diff --git a/lang/python/tests/t-idiomatic.py b/lang/python/tests/t-idiomatic.py index 4df8742c..485f0486 100755 --- a/lang/python/tests/t-idiomatic.py +++ b/lang/python/tests/t-idiomatic.py @@ -27,7 +27,7 @@ import tempfile  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  # Both Context and Data can be used as context manager:  with gpg.Context() as c, gpg.Data() as d: @@ -40,15 +40,15 @@ assert leak_d.wrapped == None  def sign_and_verify(source, signed, sink):      with gpg.Context() as c: -        c.op_sign(source, signed, gpg.constants.SIG_MODE_NORMAL) +        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 == (gpg.constants.SIGSUM_VALID | -                           gpg.constants.SIGSUM_GREEN) +    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) diff --git a/lang/python/tests/t-import.py b/lang/python/tests/t-import.py index 68ad6d7d..5b0576f2 100755 --- a/lang/python/tests/t-import.py +++ b/lang/python/tests/t-import.py @@ -67,7 +67,7 @@ def check_result(result, fpr, secret):      assert len(result.imports) == 1 or fpr == result.imports[1].fpr      assert result.imports[0].result == 0 -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.op_import(gpg.Data(file=support.make_filename("pubkey-1.asc"))) diff --git a/lang/python/tests/t-keylist.py b/lang/python/tests/t-keylist.py index a7259419..ea2a7240 100755 --- a/lang/python/tests/t-keylist.py +++ b/lang/python/tests/t-keylist.py @@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  # Check expration of keys.  This test assumes three subkeys of which @@ -108,7 +108,7 @@ def check_global(key, uids, n_subkeys):      assert key.can_sign, "Key unexpectedly unusable for signing"      assert key.can_certify, "Key unexpectedly unusable for certifications"      assert not key.secret, "Key unexpectedly secret" -    assert not key.protocol != gpg.constants.PROTOCOL_OpenPGP, \ +    assert not key.protocol != gpg.constants.protocol.OpenPGP, \          "Key has unexpected protocol: {}".format(key.protocol)      assert not key.issuer_serial, \          "Key unexpectedly carries issuer serial: {}".format(key.issuer_serial) @@ -119,10 +119,10 @@ def check_global(key, uids, n_subkeys):      # Only key Alfa is trusted      assert key.uids[0].name == 'Alfa Test' \ -      or key.owner_trust == gpg.constants.VALIDITY_UNKNOWN, \ +      or key.owner_trust == gpg.constants.validity.UNKNOWN, \          "Key has unexpected owner trust: {}".format(key.owner_trust)      assert key.uids[0].name != 'Alfa Test' \ -      or key.owner_trust == gpg.constants.VALIDITY_ULTIMATE, \ +      or key.owner_trust == gpg.constants.validity.ULTIMATE, \          "Key has unexpected owner trust: {}".format(key.owner_trust)      assert len(key.subkeys) - 1 == n_subkeys, \ @@ -153,8 +153,8 @@ def check_subkey(fpr, which, subkey):      assert not subkey.secret, which + " key unexpectedly secret"      assert not subkey.is_cardkey, "Public key marked as card key"      assert not subkey.card_number, "Public key with card number set" -    assert not subkey.pubkey_algo != (gpg.constants.PK_DSA if which == "Primary" -                                      else gpg.constants.PK_ELG_E), \ +    assert not subkey.pubkey_algo != (gpg.constants.pk.DSA if which == "Primary" +                                      else gpg.constants.pk.ELG_E), \          which + " key has unexpected public key algo: {}".\              format(subkey.pubkey_algo)      assert subkey.length == 1024, \ @@ -169,10 +169,10 @@ def check_subkey(fpr, which, subkey):  def check_uid(which, ref, uid):      assert not uid.revoked, which + " user ID unexpectedly revoked"      assert not uid.invalid, which + " user ID unexpectedly invalid" -    assert uid.validity == (gpg.constants.VALIDITY_UNKNOWN +    assert uid.validity == (gpg.constants.validity.UNKNOWN                              if uid.name.split()[0]                              not in {'Alfa', 'Alpha', 'Alice'} else -                            gpg.constants.VALIDITY_ULTIMATE), \ +                            gpg.constants.validity.ULTIMATE), \        which + " user ID has unexpectedly validity: {}".format(uid.validity)      assert not uid.signatures, which + " user ID unexpectedly signed"      assert uid.name == ref[0], \ diff --git a/lang/python/tests/t-protocol-assuan.py b/lang/python/tests/t-protocol-assuan.py index ad22ae3f..0084a6bd 100755 --- a/lang/python/tests/t-protocol-assuan.py +++ b/lang/python/tests/t-protocol-assuan.py @@ -22,7 +22,7 @@ del absolute_import, print_function, unicode_literals  import gpg -with gpg.Context(protocol=gpg.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') diff --git a/lang/python/tests/t-sig-notation.py b/lang/python/tests/t-sig-notation.py index 050ef6be..f1342b1f 100755 --- a/lang/python/tests/t-sig-notation.py +++ b/lang/python/tests/t-sig-notation.py @@ -25,10 +25,10 @@ import gpg  import support  expected_notations = { -    "laughing@me": ("Just Squeeze Me", gpg.constants.SIG_NOTATION_HUMAN_READABLE), +    "laughing@me": ("Just Squeeze Me", gpg.constants.sig.notation.HUMAN_READABLE),      "[email protected]": ("pgpmime", -                                         gpg.constants.SIG_NOTATION_HUMAN_READABLE -                                         | gpg.constants.SIG_NOTATION_CRITICAL), +                                         gpg.constants.sig.notation.HUMAN_READABLE +                                         | gpg.constants.sig.notation.CRITICAL),      None: ("http://www.gnu.org/policy/", 0),  } @@ -55,14 +55,14 @@ def check_result(result):          assert r.value == value, \              "Expected {!r}, got {!r}".format(value, r.value)          assert r.human_readable \ -            == bool(flags & gpg.constants.SIG_NOTATION_HUMAN_READABLE) +            == bool(flags & gpg.constants.sig.notation.HUMAN_READABLE)          assert r.critical \ -            == (bool(flags & gpg.constants.SIG_NOTATION_CRITICAL) +            == (bool(flags & gpg.constants.sig.notation.CRITICAL)                  if have_correct_sig_data else False)      assert len(expected_notations) == 0 -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  source = gpg.Data("Hallo Leute\n")  signed = gpg.Data() @@ -71,7 +71,7 @@ c = gpg.Context()  for name, (value, flags) in expected_notations.items():      c.sig_notation_add(name, value, flags) -c.op_sign(source, signed, gpg.constants.SIG_MODE_NORMAL) +c.op_sign(source, signed, gpg.constants.sig.mode.NORMAL)  signed.seek(0, os.SEEK_SET)  sink = gpg.Data() diff --git a/lang/python/tests/t-sign.py b/lang/python/tests/t-sign.py index c15b68c9..9418ed88 100755 --- a/lang/python/tests/t-sign.py +++ b/lang/python/tests/t-sign.py @@ -38,11 +38,11 @@ def check_result(r, typ):      if signature.type != typ:          fail("Wrong type of signature created") -    if signature.pubkey_algo != gpg.constants.PK_DSA: +    if signature.pubkey_algo != gpg.constants.pk.DSA:          fail("Wrong pubkey algorithm reported: {}".format(              signature.pubkey_algo)) -    if signature.hash_algo != gpg.constants.MD_SHA1: +    if signature.hash_algo != gpg.constants.md.SHA1:          fail("Wrong hash algorithm reported: {}".format(              signature.hash_algo)) @@ -54,7 +54,7 @@ def check_result(r, typ):          fail("Wrong fingerprint reported: {}".format(signature.fpr)) -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_textmode(True)  c.set_armor(True) @@ -62,30 +62,30 @@ c.set_armor(True)  source = gpg.Data("Hallo Leute\n")  sink = gpg.Data() -c.op_sign(source, sink, gpg.constants.SIG_MODE_NORMAL) +c.op_sign(source, sink, gpg.constants.sig.mode.NORMAL)  result = c.op_sign_result() -check_result(result, gpg.constants.SIG_MODE_NORMAL) +check_result(result, gpg.constants.sig.mode.NORMAL)  support.print_data(sink)  # Now a detached signature.  source.seek(0, os.SEEK_SET)  sink = gpg.Data() -c.op_sign(source, sink, gpg.constants.SIG_MODE_DETACH) +c.op_sign(source, sink, gpg.constants.sig.mode.DETACH)  result = c.op_sign_result() -check_result(result, gpg.constants.SIG_MODE_DETACH) +check_result(result, gpg.constants.sig.mode.DETACH)  support.print_data(sink)  # And finally a cleartext signature.  */  source.seek(0, os.SEEK_SET)  sink = gpg.Data() -c.op_sign(source, sink, gpg.constants.SIG_MODE_CLEAR) +c.op_sign(source, sink, gpg.constants.sig.mode.CLEAR)  result = c.op_sign_result() -check_result(result, gpg.constants.SIG_MODE_CLEAR) +check_result(result, gpg.constants.sig.mode.CLEAR)  support.print_data(sink)  # Idiomatic interface. @@ -95,11 +95,11 @@ with gpg.Context(armor=True, textmode=True) as c:      assert len(signed) > 0      assert signed.find(b'BEGIN PGP MESSAGE') > 0, 'Message not found' -    signed, _ = c.sign(message, mode=gpg.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=gpg.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' diff --git a/lang/python/tests/t-signers.py b/lang/python/tests/t-signers.py index 13e039bb..80e797c9 100755 --- a/lang/python/tests/t-signers.py +++ b/lang/python/tests/t-signers.py @@ -37,11 +37,11 @@ def check_result(r, typ):          if signature.type != typ:              fail("Wrong type of signature created") -        if signature.pubkey_algo != gpg.constants.PK_DSA: +        if signature.pubkey_algo != gpg.constants.pk.DSA:              fail("Wrong pubkey algorithm reported: {}".format(                  signature.pubkey_algo)) -        if signature.hash_algo != gpg.constants.MD_SHA1: +        if signature.hash_algo != gpg.constants.md.SHA1:              fail("Wrong hash algorithm reported: {}".format(                  signature.hash_algo)) @@ -54,7 +54,7 @@ def check_result(r, typ):              fail("Wrong fingerprint reported: {}".format(signature.fpr)) -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_textmode(True)  c.set_armor(True) @@ -68,8 +68,8 @@ c.op_keylist_end()  c.signers_add(keys[0])  c.signers_add(keys[1]) -for mode in (gpg.constants.SIG_MODE_NORMAL, gpg.constants.SIG_MODE_DETACH, -             gpg.constants.SIG_MODE_CLEAR): +for mode in (gpg.constants.sig.mode.NORMAL, gpg.constants.sig.mode.DETACH, +             gpg.constants.sig.mode.CLEAR):      source = gpg.Data("Hallo Leute\n")      sink = gpg.Data() @@ -83,15 +83,15 @@ for mode in (gpg.constants.SIG_MODE_NORMAL, gpg.constants.SIG_MODE_DETACH,  with gpg.Context(armor=True, textmode=True, signers=keys) as c:      message = "Hallo Leute\n".encode()      signed, result = c.sign(message) -    check_result(result, gpg.constants.SIG_MODE_NORMAL) +    check_result(result, gpg.constants.sig.mode.NORMAL)      assert signed.find(b'BEGIN PGP MESSAGE') > 0, 'Message not found' -    signed, result = c.sign(message, mode=gpg.constants.SIG_MODE_DETACH) -    check_result(result, gpg.constants.SIG_MODE_DETACH) +    signed, result = c.sign(message, mode=gpg.constants.sig.mode.DETACH) +    check_result(result, gpg.constants.sig.mode.DETACH)      assert signed.find(b'BEGIN PGP SIGNATURE') > 0, 'Signature not found' -    signed, result = c.sign(message, mode=gpg.constants.SIG_MODE_CLEAR) -    check_result(result, gpg.constants.SIG_MODE_CLEAR) +    signed, result = c.sign(message, mode=gpg.constants.sig.mode.CLEAR) +    check_result(result, gpg.constants.sig.mode.CLEAR)      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' diff --git a/lang/python/tests/t-trustlist.py b/lang/python/tests/t-trustlist.py index 5db09548..8c5e2143 100755 --- a/lang/python/tests/t-trustlist.py +++ b/lang/python/tests/t-trustlist.py @@ -23,7 +23,7 @@ del absolute_import, print_function, unicode_literals  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  def dump_item(item): diff --git a/lang/python/tests/t-verify.py b/lang/python/tests/t-verify.py index ddfa2ced..f18e1ddc 100755 --- a/lang/python/tests/t-verify.py +++ b/lang/python/tests/t-verify.py @@ -98,7 +98,7 @@ def check_result(result, summary, validity, fpr, status, notation):      assert gpg.errors.GPGMEError(sig.validity_reason).getcode() == gpg.errors.NO_ERROR -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) @@ -107,8 +107,8 @@ text = gpg.Data(test_text1)  sig = gpg.Data(test_sig1)  c.op_verify(sig, text, None)  result = c.op_verify_result() -check_result(result, gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, -             gpg.constants.VALIDITY_FULL, +check_result(result, gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN, +             gpg.constants.validity.FULL,               "A0FF4590BB6122EDEF6E3C542D727CC768697734",               gpg.errors.NO_ERROR, True) @@ -118,7 +118,7 @@ text = gpg.Data(test_text1f)  sig.seek(0, os.SEEK_SET)  c.op_verify(sig, text, None)  result = c.op_verify_result() -check_result(result, gpg.constants.SIGSUM_RED, gpg.constants.VALIDITY_UNKNOWN, +check_result(result, gpg.constants.sigsum.RED, gpg.constants.validity.UNKNOWN,               "2D727CC768697734", gpg.errors.BAD_SIGNATURE, False)  # Checking a normal signature. @@ -126,8 +126,8 @@ text = gpg.Data()  sig = gpg.Data(test_sig2)  c.op_verify(sig, None, text)  result = c.op_verify_result() -check_result(result, gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, -             gpg.constants.VALIDITY_FULL, +check_result(result, gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN, +             gpg.constants.validity.FULL,               "A0FF4590BB6122EDEF6E3C542D727CC768697734",               gpg.errors.NO_ERROR, False) @@ -147,8 +147,8 @@ else:  with gpg.Context(armor=True) as c:      # Checking a valid message.      _, result = c.verify(test_text1, test_sig1) -    check_result(result, gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, -                 gpg.constants.VALIDITY_FULL, +    check_result(result, gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN, +                 gpg.constants.validity.FULL,                   "A0FF4590BB6122EDEF6E3C542D727CC768697734",                   gpg.errors.NO_ERROR, True) @@ -156,8 +156,8 @@ with gpg.Context(armor=True) as c:      try:          c.verify(test_text1f, test_sig1)      except gpg.errors.BadSignatures as e: -        check_result(e.result, gpg.constants.SIGSUM_RED, -                     gpg.constants.VALIDITY_UNKNOWN, +        check_result(e.result, gpg.constants.sigsum.RED, +                     gpg.constants.validity.UNKNOWN,                       "2D727CC768697734", gpg.errors.BAD_SIGNATURE, False)      else:          assert False, "Expected an error but got none." @@ -165,8 +165,8 @@ with gpg.Context(armor=True) as c:      # Checking a normal signature.      sig = gpg.Data(test_sig2)      data, result = c.verify(test_sig2) -    check_result(result, gpg.constants.SIGSUM_VALID | gpg.constants.SIGSUM_GREEN, -                 gpg.constants.VALIDITY_FULL, +    check_result(result, gpg.constants.sigsum.VALID | gpg.constants.sigsum.GREEN, +                 gpg.constants.validity.FULL,                   "A0FF4590BB6122EDEF6E3C542D727CC768697734",                   gpg.errors.NO_ERROR, False)      assert data == test_text1 diff --git a/lang/python/tests/t-wait.py b/lang/python/tests/t-wait.py index d4217b5b..b1f2043f 100755 --- a/lang/python/tests/t-wait.py +++ b/lang/python/tests/t-wait.py @@ -24,7 +24,7 @@ import time  import gpg  import support -support.init_gpgme(gpg.constants.PROTOCOL_OpenPGP) +support.init_gpgme(gpg.constants.protocol.OpenPGP)  c = gpg.Context()  c.set_armor(True) | 
