[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

parsing encrypted netrc file


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,
        info = netrc.netrc(

which fails as the temporary file doesn't even get created.