def gpg_decrypt(filename, passphrase):
    stderr = tempfile.TemporaryFile()
    source = open(filename)

    with nested(stderr, source):
        gnupg = GnuPG(['--armor'])

        gnupg.run(
            ['--decrypt'],
            create_fhs=['stdout', 'passphrase'],
            attach_fhs={
                'stdin': source,
                'stderr': stderr,
            })

        gnupg.handles['passphrase'].write(passphrase)
        gnupg.handles['passphrase'].close()

        content = gnupg.handles['stdout'].read()
    try:
        gnupg.wait()
    except __HOLE__:
        return b''
    else:
        return content
dataset/ETHPy150Open akheron/sala/sala/gpg.py/gpg_decrypt