diff options
author | Justus Winter <[email protected]> | 2016-05-17 12:15:21 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-05-17 12:22:22 +0000 |
commit | 10328324c8fc9725cd0c885eaebfc80dc32c1ff6 (patch) | |
tree | 425531ecd2daf5eb85caf1229b62a0834ec6132b /lang/python/examples/signverify.py | |
parent | python: Import GPGMEError. (diff) | |
download | gpgme-10328324c8fc9725cd0c885eaebfc80dc32c1ff6.tar.gz gpgme-10328324c8fc9725cd0c885eaebfc80dc32c1ff6.zip |
python: Clean up examples.
* lang/python/examples/delkey.py: Clean up example.
* lang/python/examples/encrypt-to-all.py: Likewise.
* lang/python/examples/genkey.py: Likewise.
* lang/python/examples/inter-edit.py: Likewise.
* lang/python/examples/sign.py: Likewise.
* lang/python/examples/signverify.py: Likewise.
* lang/python/examples/simple.py: Likewise.
* lang/python/examples/t-edit.py: Likewise.
* lang/python/examples/verifydetails.py: Likewise.
* lang/python/pyme/__init__.py: Likewise.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rwxr-xr-x | lang/python/examples/signverify.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lang/python/examples/signverify.py b/lang/python/examples/signverify.py index 7194157b..292deee9 100755 --- a/lang/python/examples/signverify.py +++ b/lang/python/examples/signverify.py @@ -20,7 +20,8 @@ # It uses keys for [email protected] generated by genkey.pl script import sys -from pyme import core, callbacks +import os +from pyme import core from pyme.constants.sig import mode core.check_version(None) @@ -28,7 +29,7 @@ core.check_version(None) plain = core.Data(b"Test message") sig = core.Data() c = core.Context() -user = b"[email protected]" +user = "joe" c.signers_clear() # Add [email protected]'s keys in the list of signers @@ -50,9 +51,9 @@ c.set_passphrase_cb(lambda x,y,z: passlist[x[x.rindex("<"):]]) c.op_sign(plain, sig, mode.CLEAR) # Print out the signature (don't forget to rewind since signing put sig at EOF) -sig.seek(0,0) +sig.seek(0, os.SEEK_SET) signedtext = sig.read() -print(signedtext) +sys.stdout.buffer.write(signedtext) # Create Data with signed text. sig2 = core.Data(signedtext) @@ -63,9 +64,7 @@ c.op_verify(sig2, None, plain2) result = c.op_verify_result() # List results for all signatures. Status equal 0 means "Ok". -index = 0 -for sign in result.signatures: - index += 1 +for index, sign in enumerate(result.signatures): print("signature", index, ":") print(" summary: ", sign.summary) print(" status: ", sign.status) @@ -74,5 +73,6 @@ for sign in result.signatures: print(" uid: ", c.get_key(sign.fpr, 0).uids[0].uid) # Print "unsigned" text. Rewind since verify put plain2 at EOF. -plain2.seek(0,0) -print("\n", plain2.read()) +plain2.seek(0, os.SEEK_SET) +print("\n") +sys.stdout.buffer.write(plain2.read()) |