def get_paging_service(chamber, limit): from sunlight.pagination import PagingService paging_service = PagingService(congress) members = list(paging_service.legislators(chamber=chamber, limit=limit)) return members
def test_non_pageable_service(self): """Services that are not pageable should result in an exception being raised when instantiating the PagingService. """ with self.assertRaises(ValueError): PagingService(OpenCivic())
def fetch_bills_info(): """ downlaods bill metadata from the sunlight api currently it downloads all the bills available in sunlight api consider supporting other filters in the future, like time ..etc """ congress = Congress() congress = PagingService(congress) results = list (congress.bills(fields="versions,history,title,urls,id" ,limit=sys.maxint ) ) return results
def setUp(self): self.congress = Congress() self.paginator = PagingService(self.congress)
from sunlight.pagination import PagingService from raven import Client as Raven from .models import connection from .schedule import delay_until_local from norrin import settings from norrin.util import day_before, yesterday, format_billid logger = logging.getLogger('norrin.notifications') airship = ua.Airship(settings.UA_KEY, settings.UA_MASTER) # terrible, terrible hack because of no sslv3 import sunlight.services.congress sunlight.services.congress.API_ROOT = 'http://congress.api.sunlightfoundation.com' congress = PagingService(congress) class AdapterRegistry(object): def __init__(self): self._adapters = [] def __iter__(self): for adapter in self._adapters: yield adapter def register(self, adapter): if isinstance(adapter, type): adapter = adapter() if adapter not in self._adapters: self._adapters.append(adapter)