def party_affiliation(name):
    parties = {'R': 'republican', 'D': 'democrat', 'I': 'independent'}
    party_abbrev = re.search('\[([A-Z])-[A-Z]{2}[^\]]*\]', name).groups()[0]
    try:
        return parties[party_abbrev]
    except KeyError:
        return party_abbrev
Handle start of stream event
dataset/ETHPy150Open croach/pydata2013/govtrack.py/party_affiliation--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/yaml_listener.py/EventHandler.StreamStart