[git] GPGME - branch, master, updated. gpgme-1.11.1-82-gcacca62

by Ben McGinnes cvs at cvs.gnupg.org
Sat Jul 7 19:42:46 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  cacca62d06c6cf4a291f7ab2571cf52d671d140f (commit)
      from  66c2a99422dd9a52d8342165ed1d033c4f29b9e0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cacca62d06c6cf4a291f7ab2571cf52d671d140f
Author: Ben McGinnes <ben at adversary.org>
Date:   Sun Jul 8 03:40:35 2018 +1000

    python bindings: howto examples
    
    * Made sure all example scripts meet PEP8 compliance.
    * Required fixing approx. a dozen of them in minor ways.

diff --git a/lang/python/examples/howto/decrypt-file.py b/lang/python/examples/howto/decrypt-file.py
index b38acc7..2fe37f2 100755
--- a/lang/python/examples/howto/decrypt-file.py
+++ b/lang/python/examples/howto/decrypt-file.py
@@ -32,10 +32,10 @@ if len(sys.argv) == 3:
     newfile = sys.argv[2]
 elif len(sys.argv) == 2:
     ciphertext = sys.argv[1]
-    newfile = input("Enter path and filename of file to save decrypted data to: ")
+    newfile = input("Enter path and filename to save decrypted data to: ")
 else:
     ciphertext = input("Enter path and filename of encrypted file: ")
-    newfile = input("Enter path and filename of file to save decrypted data to: ")
+    newfile = input("Enter path and filename to save decrypted data to: ")
 
 with open(ciphertext, "rb") as cfile:
     try:
diff --git a/lang/python/examples/howto/encrypt-file.py b/lang/python/examples/howto/encrypt-file.py
index ad4e1ce..7c84a6f 100755
--- a/lang/python/examples/howto/encrypt-file.py
+++ b/lang/python/examples/howto/encrypt-file.py
@@ -3,6 +3,9 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,9 +27,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import sys
-
 """
 Encrypts a file to a specified key.  If entering both the key and the filename
 on the command line, the key must be entered first.
@@ -55,7 +55,7 @@ with open(filename, "rb") as f:
 with gpg.Context(armor=True) as ca:
     try:
         ciphertext, result, sign_result = ca.encrypt(text, recipients=rkey,
-                                                    sign=False)
+                                                     sign=False)
         with open("{0}.asc".format(filename), "wb") as fa:
             fa.write(ciphertext)
     except gpg.errors.InvalidRecipients as e:
@@ -64,7 +64,7 @@ with gpg.Context(armor=True) as ca:
 with gpg.Context() as cg:
     try:
         ciphertext, result, sign_result = cg.encrypt(text, recipients=rkey,
-                                                    sign=False)
+                                                     sign=False)
         with open("{0}.gpg".format(filename), "wb") as fg:
             fg.write(ciphertext)
     except gpg.errors.InvalidRecipients as e:
diff --git a/lang/python/examples/howto/encrypt-sign-file.py b/lang/python/examples/howto/encrypt-sign-file.py
index 41aaac8..a08176b 100755
--- a/lang/python/examples/howto/encrypt-sign-file.py
+++ b/lang/python/examples/howto/encrypt-sign-file.py
@@ -3,6 +3,9 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,9 +27,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import sys
-
 """
 Signs and encrypts a file to a specified key.  If entering both the key and the
 filename on the command line, the key must be entered first.
@@ -58,13 +58,13 @@ with open(filename, "rb") as f:
 with gpg.Context(armor=True) as ca:
     ciphertext, result, sign_result = ca.encrypt(text, recipients=rkey,
                                                  always_trust=True,
-                                                     add_encrypt_to=True)
+                                                 add_encrypt_to=True)
     with open("{0}.asc".format(filename), "wb") as fa:
         fa.write(ciphertext)
 
 with gpg.Context() as cg:
     ciphertext, result, sign_result = cg.encrypt(text, recipients=rkey,
                                                  always_trust=True,
-                                                     add_encrypt_to=True)
+                                                 add_encrypt_to=True)
     with open("{0}.gpg".format(filename), "wb") as fg:
         fg.write(ciphertext)
diff --git a/lang/python/examples/howto/encrypt-to-group-gullible.py b/lang/python/examples/howto/encrypt-to-group-gullible.py
index 7ebfb6b..c96e829 100755
--- a/lang/python/examples/howto/encrypt-to-group-gullible.py
+++ b/lang/python/examples/howto/encrypt-to-group-gullible.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import sys
+from groups import group_lists
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import sys
-from groups import group_lists
-
 """
 Uses the groups module to encrypt to multiple recipients.
 
@@ -74,7 +74,7 @@ if klist is not None:
                                                     add_encrypt_to=True,
                                                     always_trust=True)
     with open("{0}.asc".format(filepath), "wb") as f:
-              f.write(ciphertext)
+        f.write(ciphertext)
 else:
     pass
 
diff --git a/lang/python/examples/howto/encrypt-to-group-trustno1.py b/lang/python/examples/howto/encrypt-to-group-trustno1.py
index 736c5f1..da0376b 100755
--- a/lang/python/examples/howto/encrypt-to-group-trustno1.py
+++ b/lang/python/examples/howto/encrypt-to-group-trustno1.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import sys
+from groups import group_lists
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import sys
-from groups import group_lists
-
 """
 Uses the groups module to encrypt to multiple recipients.
 
@@ -83,7 +83,7 @@ if klist is not None:
         except:
             pass
     with open("{0}.asc".format(filepath), "wb") as f:
-              f.write(ciphertext)
+        f.write(ciphertext)
 else:
     pass
 
diff --git a/lang/python/examples/howto/encrypt-to-group.py b/lang/python/examples/howto/encrypt-to-group.py
index 84f8d10..d4cb074 100755
--- a/lang/python/examples/howto/encrypt-to-group.py
+++ b/lang/python/examples/howto/encrypt-to-group.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import sys
+from groups import group_lists
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import sys
-from groups import group_lists
-
 """
 Uses the groups module to encrypt to multiple recipients.
 
@@ -84,7 +84,7 @@ if klist is not None:
         except:
             pass
     with open("{0}.asc".format(filepath), "wb") as f:
-              f.write(ciphertext)
+        f.write(ciphertext)
 else:
     pass
 
diff --git a/lang/python/examples/howto/export-key.py b/lang/python/examples/howto/export-key.py
index 41be64f..6def687 100755
--- a/lang/python/examples/howto/export-key.py
+++ b/lang/python/examples/howto/export-key.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os.path
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os.path
-import sys
-
 print("""
 This script exports one or more public keys.
 """)
diff --git a/lang/python/examples/howto/export-minimised-key.py b/lang/python/examples/howto/export-minimised-key.py
index d28b1cb..c2c533e 100755
--- a/lang/python/examples/howto/export-minimised-key.py
+++ b/lang/python/examples/howto/export-minimised-key.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os.path
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os.path
-import sys
-
 print("""
 This script exports one or more public keys in minimised form.
 """)
diff --git a/lang/python/examples/howto/export-secret-key.py b/lang/python/examples/howto/export-secret-key.py
index 8bbe409..e9c53fe 100755
--- a/lang/python/examples/howto/export-secret-key.py
+++ b/lang/python/examples/howto/export-secret-key.py
@@ -3,6 +3,11 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os
+import os.path
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,11 +29,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os
-import os.path
-import sys
-
 print("""
 This script exports one or more secret keys.
 
diff --git a/lang/python/examples/howto/export-secret-keys.py b/lang/python/examples/howto/export-secret-keys.py
index 03037c9..f0a791e 100755
--- a/lang/python/examples/howto/export-secret-keys.py
+++ b/lang/python/examples/howto/export-secret-keys.py
@@ -3,6 +3,12 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os
+import os.path
+import subprocess
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,12 +30,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os
-import os.path
-import subprocess
-import sys
-
 print("""
 This script exports one or more secret keys as both ASCII armored and binary
 file formats, saved in files within the user's GPG home directory.
diff --git a/lang/python/examples/howto/import-key.py b/lang/python/examples/howto/import-key.py
index 56cfe25..464052d 100755
--- a/lang/python/examples/howto/import-key.py
+++ b/lang/python/examples/howto/import-key.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os.path
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os.path
-import sys
-
 print("""
 This script exports one or more public keys.
 """)
diff --git a/lang/python/examples/howto/import-keys.py b/lang/python/examples/howto/import-keys.py
index 8a3bb29..bdc15a6 100755
--- a/lang/python/examples/howto/import-keys.py
+++ b/lang/python/examples/howto/import-keys.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import gpg
+import os.path
+import requests
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,21 +28,14 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import gpg
-import os.path
-import requests
-
 print("""
 This script imports one or more public keys from the SKS keyservers.
 """)
 
-import gpg
-import requests
-
 c = gpg.Context()
 url = "https://sks-keyservers.net/pks/lookup"
 pattern = input("Enter the pattern to search for key or user IDs: ")
-payload = { "op": "get", "search": pattern }
+payload = {"op": "get", "search": pattern}
 
 r = requests.get(url, verify=True, params=payload)
 result = c.key_import(r.content)
diff --git a/lang/python/examples/howto/temp-homedir-config.py b/lang/python/examples/howto/temp-homedir-config.py
index ddd7932..3bb5cf3 100755
--- a/lang/python/examples/howto/temp-homedir-config.py
+++ b/lang/python/examples/howto/temp-homedir-config.py
@@ -3,6 +3,10 @@
 
 from __future__ import absolute_import, division, unicode_literals
 
+import os
+import os.path
+import sys
+
 # Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -24,10 +28,6 @@ from __future__ import absolute_import, division, unicode_literals
 # Lesser General Public along with this program; if not, see
 # <http://www.gnu.org/licenses/>.
 
-import os
-import os.path
-import sys
-
 intro = """
 This script creates a temporary directory to use as a homedir for
 testing key generation tasks with the correct permissions, along
@@ -54,6 +54,13 @@ message telling you to specify a new directory name.  There is no
 default directory name.
 """
 
+ciphers256 = "TWOFISH CAMELLIA256 AES256"
+ciphers192 = "CAMELLIA192 AES192"
+ciphers128 = "CAMELLIA128 AES"
+ciphersBad = "BLOWFISH IDEA CAST5 3DES"
+digests = "SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1"
+compress = "ZLIB BZIP2 ZIP Uncompressed"
+
 gpgconf = """# gpg.conf settings for key generation:
 expert
 allow-freeform-uid
@@ -63,11 +70,11 @@ tofu-default-policy unknown
 enable-large-rsa
 enable-dsa2
 cert-digest-algo SHA512
-default-preference-list TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1 ZLIB BZIP2 ZIP Uncompressed
-personal-cipher-preferences TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES
-personal-digest-preferences SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1
-personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed
-"""
+default-preference-list {0} {1} {2} {3} {4} {5}
+personal-cipher-preferences {0} {1} {2} {3}
+personal-digest-preferences {4}
+personal-compress-preferences {5}
+""".format(ciphers256, ciphers192, ciphers128, ciphersBad, digests, compress)
 
 agentconf = """# gpg-agent.conf settings for key generation:
 default-cache-ttl 300

-----------------------------------------------------------------------

Summary of changes:
 lang/python/examples/howto/decrypt-file.py         |  4 ++--
 lang/python/examples/howto/encrypt-file.py         | 10 ++++-----
 lang/python/examples/howto/encrypt-sign-file.py    | 10 ++++-----
 .../examples/howto/encrypt-to-group-gullible.py    | 10 ++++-----
 .../examples/howto/encrypt-to-group-trustno1.py    | 10 ++++-----
 lang/python/examples/howto/encrypt-to-group.py     | 10 ++++-----
 lang/python/examples/howto/export-key.py           |  8 +++----
 lang/python/examples/howto/export-minimised-key.py |  8 +++----
 lang/python/examples/howto/export-secret-key.py    | 10 ++++-----
 lang/python/examples/howto/export-secret-keys.py   | 12 +++++------
 lang/python/examples/howto/import-key.py           |  8 +++----
 lang/python/examples/howto/import-keys.py          | 13 +++++------
 lang/python/examples/howto/temp-homedir-config.py  | 25 ++++++++++++++--------
 13 files changed, 71 insertions(+), 67 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list