From 312ee8394fdf259474e4228b5fcc99a3867431e1 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Mon, 23 May 2016 21:46:16 +0000 Subject: [PATCH 1/3] gpg.py: Add listkey() and listkeys() functions Add functions for handling --list-key and --list-keys. Both of these functions have the same signature as the fingerprint() method. listkey() and listkeys() both supply arguments after --list-key and --list-keys as inputfile parameter to runGPG(). The inputfile parameter may be the name of a filename parameter to gpg or a non-filename arguments supplied to --list-keys or --list-key such as a user's email address (uid), key id (pub/sub) or key fingerprint. --- pyGPG/gpg.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pyGPG/gpg.py b/pyGPG/gpg.py index 5aaf992..bff0908 100644 --- a/pyGPG/gpg.py +++ b/pyGPG/gpg.py @@ -111,6 +111,27 @@ class GPG(object): return GPGResult(gpg, results, extract_stdout=True) return GPGResult(gpg, results) + def listkey(self, id_string=None, outputfile=None): + '''Lists the keys with --list-key + + @param id_string: string (optional) argument to --list-key + @param outputfile: string (optional) filepath to pass to + gpg for it's output + @rtype GnuPGResult object + ''' + return self.runGPG('list-key', inputfile=id_string, + outputfile=outputfile) + + def listkeys(self, id_string=None, outputfile=None): + '''Lists the keys with --list-keys + + @param id_string: string (optional) argument to --list-keys + @param outputfile: string (optional) filepath to pass to + gpg for it's output + @rtype GnuPGResult object + ''' + return self.runGPG('list-keys', inputfile=id_string, + outputfile=outputfile) def fingerprint(self, id_string=None, outputfile=None): '''Lists the key, with the fingerprint -- 2.4.10