示例#1
0
def get_committee_id(abbr, chamber, committee):

    manual = attempt_committee_match(abbr,
                                     chamber,
                                     committee)

    if manual:
        return manual

    key = (abbr, chamber, committee)
    if key in __committee_ids:
        return __committee_ids[key]

    spec = {settings.LEVEL_FIELD: abbr, 'chamber': chamber,
            'committee': committee, 'subcommittee': None}

    comms = db.committees.find(spec)

    if comms.count() != 1:
        flag = 'Committee on'
        if flag not in committee:
            spec['committee'] = 'Committee on ' + committee
        else:
            spec['committee'] = committee.replace(flag, "").strip()
        comms = db.committees.find(spec)

    if comms and comms.count() == 1:
        __committee_ids[key] = comms[0]['_id']
    else:
        # last resort :(
        comm_id = get_committee_id_alt(abbr, committee, chamber)
        __committee_ids[key] = comm_id

    return __committee_ids[key]
示例#2
0
文件: utils.py 项目: showerst/billy
def get_committee_id(abbr, chamber, committee):

    manual = attempt_committee_match(abbr, chamber, committee)

    if manual:
        return manual

    key = (abbr, chamber, committee)
    if key in __committee_ids:
        return __committee_ids[key]

    spec = {
        settings.LEVEL_FIELD: abbr,
        'chamber': chamber,
        'committee': committee,
        'subcommittee': None
    }

    comms = db.committees.find(spec)

    if comms.count() != 1:
        flag = 'Committee on'
        if flag not in committee:
            spec['committee'] = 'Committee on ' + committee
        else:
            spec['committee'] = committee.replace(flag, "").strip()
        comms = db.committees.find(spec)

    if comms and comms.count() == 1:
        __committee_ids[key] = comms[0]['_id']
    else:
        # last resort :(
        comm_id = get_committee_id_alt(abbr, committee, chamber)
        __committee_ids[key] = comm_id

    return __committee_ids[key]