[Python-modules-commits] [python-gnupg] 03/08: always use --fixed-list-mode and --batch and --with-colons

Elena Grandi valhalla-guest at moszumanska.debian.org
Sat Apr 8 06:44:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

valhalla-guest pushed a commit to branch gpg2
in repository python-gnupg.

commit e9c796033ca3489f24468475694f6fad008c9c0b
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Fri Feb 17 17:23:06 2017 -0500

    always use --fixed-list-mode and --batch and --with-colons
    
    gpg is being invoked programmatically, so it should always use
    --batch.
    
    --fixed-list-mode is also the standard, since we have no intention of
    ever using the non-fixed mode and modern versions of GnuPG don't even
    have the option of doing so.
    
    we also want --with-colons: for any output, are going to be parsing it
    directly, so we don't want the human-readable form.
---
 gnupg.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gnupg.py b/gnupg.py
index 7ff9f11..9090599 100644
--- a/gnupg.py
+++ b/gnupg.py
@@ -733,6 +733,7 @@ class GPG(object):
         a passphrase will be sent to GPG, else False.
         """
         cmd = [self.gpgbinary, '--status-fd', '2', '--no-tty']
+        cmd.extend(['--fixed-list-mode', '--batch', '--with-colons'])
         if self.gnupghome:
             cmd.extend(['--homedir',  no_quote(self.gnupghome)])
         if self.keyring:
@@ -743,7 +744,7 @@ class GPG(object):
             for fn in self.secret_keyring:
                 cmd.extend(['--secret-keyring', no_quote(fn)])
         if passphrase:
-            cmd.extend(['--batch', '--passphrase-fd', '0'])
+            cmd.extend(['--passphrase-fd', '0'])
             if self.version >= (2,1):
                 cmd.extend(['--pinentry-mode', 'loopback'])
         if self.use_agent:  # pragma: no cover
@@ -874,7 +875,7 @@ class GPG(object):
         "If writing to a file which exists, avoid a confirmation message."
         if os.path.exists(output):
             # We need to avoid an overwrite confirmation message
-            args.extend(['--batch', '--yes'])
+            args.extend(['--yes'])
         args.extend(['--output', no_quote(output)])
 
     def sign_file(self, file, keyid=None, passphrase=None, clearsign=True,
@@ -1069,7 +1070,7 @@ class GPG(object):
             fingerprints = [no_quote(s) for s in fingerprints]
         else:
             fingerprints = [no_quote(fingerprints)]
-        args = ['--batch', '--delete-%s' % which]
+        args = ['--delete-%s' % which]
         args.extend(fingerprints)
         result = self.result_map['delete'](self)
         p = self._open_subprocess(args)
@@ -1148,9 +1149,8 @@ class GPG(object):
             which='keys'
         if secret:
             which='secret-keys'
-        args = ['--list-%s' % which, '--fixed-list-mode',
-                '--fingerprint', '--fingerprint',   # get subkey FPs, too
-                '--with-colons']
+        args = ['--list-%s' % which,
+                '--fingerprint', '--fingerprint'] # get subkey FPs, too
         if keys:
             if isinstance(keys, string_types):
                 keys = [keys]
@@ -1188,7 +1188,7 @@ class GPG(object):
         query = query.strip()
         if HEX_DIGITS_RE.match(query):
             query = '0x' + query
-        args = ['--fixed-list-mode', '--fingerprint', '--with-colons',
+        args = ['--fingerprint',
                 '--keyserver', no_quote(keyserver), '--search-keys',
                 no_quote(query)]
         p = self._open_subprocess(args)
@@ -1225,7 +1225,7 @@ class GPG(object):
         >>> assert not result
 
         """
-        args = ["--gen-key", "--batch"]
+        args = ["--gen-key"]
         result = self.result_map['generate'](self)
         f = _make_binary_stream(input, self.encoding)
         self._handle_io(args, f, result, binary=True)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-gnupg.git



More information about the Python-modules-commits mailing list