#!/usr/bin/python

import re, os

def get_password_emacs(machine, login, port):
    s = "machine %s login %s port %s password ([^ ]*)\n" % (machine, login, port)
    p = re.compile(s)
    authinfo = os.popen("gpg -q -d ~/.authinfo.gpg").read()
    return p.search(authinfo).group(1)

#!/usr/bin/python

import re, os

def get_password_emacs(machine, login, port):
    """Return password for the given machine/login/port.

    Your .authinfo.gpg file had better follow the following order, or
    you will not get a result.
    """
    s = "machine %s login %s port %s password ([^ ]*)\n" % (machine, login, port)
    p = re.compile(s)
    authinfo = os.popen("gpg -q -d ~/.authinfo.gpg").read()
    return p.search(authinfo).group(1)

Add a comment for the get_password_emacs function
Add a comment for the get_password_emacs function

Comment necessary because the format of authinfo needs to match the
semi-brittle regex (ah, regexes...)

This also moves the file to a proper dotfile, similar to commit
42f2b513a7949edf901b18233c1229bfcc24b706
