parsing encrypted netrc file
Seb
spluque at gmail.com
Mon Jun 22 18:38:52 EDT 2020
Hello,
What's the pythonic way to do this without polluting the user's
directory with the decrypted file? I wrongly thought this should do it:
import os.path as osp
import gnupg
import netrc
import tempfile
gpg = gnupg.GPG()
with open(osp.expanduser("~/.authinfo.gpg"), "rb") as f:
with tempfile.NamedTemporaryFile("w+") as tf:
status = gpg.decrypt_file(f, output=tf.name)
info = netrc.netrc(tf.name)
which fails as the temporary file doesn't even get created.
--
Seb
More information about the Python-list
mailing list