Ejemplo n.º 1
0
def combine():
    watchdog_map = {}
    govtrack_map = {}

    print "Processing govtrack.us basics."
    for pol in govtrack.parse_basics():
        wd = get_wd_id(pol.id)
        if not wd: continue
        current_member = wd.get('current_member')
        watchdog_id = wd['watchdog_id']
        govtrack_map[
            pol.id] = watchdog_map[watchdog_id] = newpol = web.storage()

        newpol['current_member'] = current_member

        for k, v in mapping.iteritems():
            if k in pol: newpol[v] = pol[k]

    print "Processing govtrack.us stats."
    for pol in govtrack.parse_stats(
        ['enacted', 'introduced', 'cosponsor', 'speeches']):
        if pol.id not in govtrack_map:
            continue
        else:
            newpol = govtrack_map[pol.id]

        if pol.get('SponsorEnacted'):
            newpol.n_bills_introduced = int(pol.NumSponsor)
            newpol.n_bills_enacted = int(pol.SponsorEnacted)

        if pol.get('SponsorIntroduced'):
            newpol.n_bills_debated = int(pol.NumSponsor) - int(
                pol.SponsorIntroduced)

        if pol.get('NumCosponsor'):
            newpol.n_bills_cosponsored = int(pol.NumCosponsor)

        if pol.get('Speeches'):
            newpol.n_speeches = int(pol.Speeches)
            newpol.words_per_speech = int(pol.WordsPerSpeech)
    return watchdog_map
Ejemplo n.º 2
0
def combine():
    watchdog_map = {}
    govtrack_map = {}

    print "Processing govtrack.us basics."
    for pol in govtrack.parse_basics():
        wd = get_wd_id(pol.id)
        if not wd:
            continue
        current_member = wd.get("current_member")
        watchdog_id = wd["watchdog_id"]
        govtrack_map[pol.id] = watchdog_map[watchdog_id] = newpol = web.storage()

        newpol["current_member"] = current_member

        for k, v in mapping.iteritems():
            if k in pol:
                newpol[v] = pol[k]

    print "Processing govtrack.us stats."
    for pol in govtrack.parse_stats(["enacted", "introduced", "cosponsor", "speeches"]):
        if pol.id not in govtrack_map:
            continue
        else:
            newpol = govtrack_map[pol.id]

        if pol.get("SponsorEnacted"):
            newpol.n_bills_introduced = int(pol.NumSponsor)
            newpol.n_bills_enacted = int(pol.SponsorEnacted)

        if pol.get("SponsorIntroduced"):
            newpol.n_bills_debated = int(pol.NumSponsor) - int(pol.SponsorIntroduced)

        if pol.get("NumCosponsor"):
            newpol.n_bills_cosponsored = int(pol.NumCosponsor)

        if pol.get("Speeches"):
            newpol.n_speeches = int(pol.Speeches)
            newpol.words_per_speech = int(pol.WordsPerSpeech)
    return watchdog_map
Ejemplo n.º 3
0
def combine():
    watchdog_map = {}
    govtrack_map = {}

    for pol in govtrack.parse_basics():
        watchdog_id = tools.getWatchdogID(pol.get('represents'),pol.lastname)
        if watchdog_id:
            govtrack_map[pol.id] = watchdog_map[watchdog_id] = newpol = web.storage()
        else:
            continue

        for k, v in mapping.iteritems():
            if k in pol: newpol[v] = pol[k]
    
    for pol in govtrack.parse_stats([
      'enacted', 'introduced', 'cosponsor', 'speeches']):
        if pol.id not in govtrack_map:
            continue
        else:
            newpol = govtrack_map[pol.id]
    
        if pol.get('SponsorEnacted'):
            newpol.n_bills_introduced = int(pol.NumSponsor)
            newpol.n_bills_enacted = int(pol.SponsorEnacted)
    
        if pol.get('SponsorIntroduced'):
            newpol.n_bills_debated = int(pol.NumSponsor) - int(pol.SponsorIntroduced)
    
        if pol.get('NumCosponsor'):
            newpol.n_bills_cosponsored = int(pol.NumCosponsor)
    
        if pol.get('Speeches'):
            newpol.n_speeches = int(pol.Speeches)
            newpol.words_per_speech = int(pol.WordsPerSpeech)
    
    return watchdog_map
Ejemplo n.º 4
0
}

watchdog_map = {}
govtrack_map = {}

for pol in govtrack.parse_basics():
    watchdog_id = tools.getWatchdogID(pol.get('represents'),pol.lastname)
    if watchdog_id:
        govtrack_map[pol.id] = watchdog_map[watchdog_id] = newpol = web.storage()
    else:
        continue

    for k, v in mapping.iteritems():
        if k in pol: newpol[v] = pol[k]
    
for pol in govtrack.parse_stats(['enacted', 'introduced', 'cosponsor', 
  'speeches']):
    if pol.id not in govtrack_map:
        continue
    else:
        newpol = govtrack_map[pol.id]
    
    if pol.get('SponsorEnacted'):
        newpol.n_bills_introduced = int(pol.NumSponsor)
        newpol.n_bills_enacted = int(pol.SponsorEnacted)
    
    if pol.get('SponsorIntroduced'):
        newpol.n_bills_debated = int(pol.NumSponsor) - int(pol.SponsorIntroduced)
    
    if pol.get('NumCosponsor'):
        newpol.n_bills_cosponsored = int(pol.NumCosponsor)