Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add armor as an option on export_keys #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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