Skip to content

Commit

Permalink
Add armor as an option on export_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
comzeradd committed Aug 19, 2018
1 parent 7845714 commit fe51df2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pretty_bad_protocol/gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,14 @@ def delete_keys(self, fingerprints, secret=False, subkeys=False):
self._collect_output(p, result, stdin=p.stdin)
return result

def export_keys(self, keyids, secret=False, subkeys=False):
def export_keys(self, keyids, secret=False, subkeys=False, armor=True):
"""Export the indicated ``keyids``.
:param str keyids: A keyid or fingerprint in any format that GnuPG will
accept.
:param bool secret: If True, export only the secret key.
:param bool subkeys: If True, export the secret subkeys.
:param bool armor: If False, export the key in binary format.
"""
which = ''
if subkeys:
Expand All @@ -437,7 +438,9 @@ def export_keys(self, keyids, secret=False, subkeys=False):
if _is_list_or_tuple(keyids):
keyids = ' '.join(['%s' % k for k in keyids])

args = ["--armor"]
args = []
if armor:
args = ["--armor"]
args.append("--export{0} {1}".format(which, keyids))

p = self._open_subprocess(args)
Expand Down

0 comments on commit fe51df2

Please sign in to comment.