Return a list of list relating cosponsors to legislation.
508755
def extract_cosponsors(bill):
    
    logger.debug("Extracting Cosponsors")
    cosponsor_map = []
    cosponsors = bill.get('cosponsors', [])
    bill_id = bill.get('bill_id', None)

    for co in cosponsors:
        co_list = []
        co_list.append(co.get('thomas_id'))
        co_list.append(bill_id)
        co_list.append(co.get('district'))
        co_list.append(co.get('state'))
        cosponsor_map.append(co_list)

    logger.debug("End Extractioning Cosponsors")

    return cosponsor_map
1253874
def by_member(self, member_id, type='introduced'):
        
        path = "members/{member_id}/bills/{type}.json".format(
            member_id=member_id, type=type)
        return self.fetch(path)
780187
def get_members_in_state(self, state):
        """"""
        members = self.run_command(command='replSetGetStatus', is_eval=False)['members']
        return [member['name'] for member in members if member['state'] == state]
1109414
async def endorsements(self, root):
        
        text = root.find('ENDORSEMENTS').text
        return [Nation(name) for name in text.split(',')] if text else []
337437
def _legislator_objects(self):
        '''
        '''
        kwargs = {}

        id_getter = operator.itemgetter('leg_id')
        ids = []
        for k in ('yes', 'no', 'other'):
            ids.extend(map(id_getter, self[k + '_votes']))
        objs = db.legislators.find({'_all_ids': {'$in': ids}}, **kwargs)

        # Handy to keep a reference to the vote on each legislator.
        objs = list(objs)
        id_cache = {}
        for obj in objs:
            obj.vote = self
            for _id in obj['_all_ids']:
                id_cache[_id] = obj

        return id_cache
142840
def list_members(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request
        return self.list('members', self.members_path, retrieve_all,
                         **_params)
1102287
def add_member(self, legislator, role='member', **kwargs):
        
        self['members'].append(dict(name=legislator, role=role,
                                    **kwargs))
1192007
def add_companion(self, bill_id, session=None, chamber=None):
        
        companion = {'bill_id': bill_id,
                     'session': session or self['session'],
                     'chamber': chamber}
        self['companions'].append(companion)
157120
def open_connections(self):
        """"""
        return [(host, len(li)) for (host, li) in self._cm.get_all().items()]
1070460
def list_members(context, request):
    """"""
    members = context.members()
    return {
        'users': [{
            'username': m.identifier,
            'userid': m.userid,
            'roles': context.get_member_roles(m.userid),
            'links': [rellink(m, request)]
        } for m in members]
    }
928808
def associations(self, subject, object=None):
        
        if object is None:
            if self.associations_by_subj is not None:
                return self.associations_by_subj[subject]
            else:
                return []
        else:
            if self.associations_by_subj_obj is not None:
                return self.associations_by_subj_obj[(subject,object)]
            else:
                return []
1183497
def get_related(self):

		'''
		
		'''

		if self.exists and hasattr(self.rdf.triples, 'ore') and hasattr(self.rdf.triples.ore, 'aggregates'):
			related = [ self.repo.parse_uri(uri) for uri in self.rdf.triples.ore.aggregates ]

			# return
			return related

		else:
			return []
906697
def get_collaborators(self, affiliation=github.GithubObject.NotSet):
        

        url_parameters = dict()
        allowed_affiliations = ['outside', 'direct', 'all']
        if affiliation is not github.GithubObject.NotSet:
            assert isinstance(affiliation, str), affiliation
            assert affiliation in allowed_affiliations, \
                'Affiliation can be one of ' + ', '.join(allowed_affiliations)
            url_parameters['affiliation'] = affiliation

        return github.PaginatedList.PaginatedList(
            github.NamedUser.NamedUser,
            self._requester,
            self.url + "/collaborators",
            url_parameters
        )
32457
def get_related(page):
    
    related = []
    entry   = Entry.get_for_model(page)

    if entry:
        related = entry.related

    return related
766647
def descendants(self):
        
        return self.members + \
            [submember for member in self.members for submember in member.descendants]
872618
def committees_legislators(self, *args, **kwargs):
        '''
        '''
        committees = list(self.committees(*args, **kwargs))
        legislators = self.legislators({'active': True},
                                       fields=['full_name',
                                               settings.LEVEL_FIELD])
        _legislators = {}

        # This will be a cache of legislator objects used in
        # the committees.html template. Includes ids in each
        # legislator's _all_ids field (if it exists.)
        for obj in legislators:
            if 'all_ids' in obj:
                for _id in obj['_all_ids']:
                    _legislators[_id] = obj
            else:
                _legislators[obj['_id']] = obj
        del legislators
        for com in committees:
            com._legislators = _legislators
        return committees
446606
def get_section_relations(Section):
    """"""
    all_rels = (Section._meta.get_all_related_objects() +
                Section._meta.get_all_related_many_to_many_objects())
    return filter_item_rels(all_rels)