def __init__(self, file_name, connection_args, actions=None): self.file_name = file_name self.engine = get_engine(**connection_args) if actions: self.actions = [self.all_actions[i - 1] for i in actions] else: self.actions = self.all_actions
def __init__(self, bbox, data_directory, graph_path, connection_args, streets=True, places=True, actions=None): engine = get_engine(**connection_args) session_factory = get_session_factory(engine) self.bbox = bbox self.bounds = Polygon.from_bounds(*bbox) self.data_directory = Path(data_directory).resolve() self.graph_path = graph_path self.engine = engine self.session = session_factory() if actions: self.actions = [self.all_actions[i - 1] for i in actions] else: self.actions = [] if streets: self.actions.extend(self.all_actions[:7]) if places: self.actions.extend(self.all_actions[7:])
def bycycle(service: arg(choices=('lookup', 'route')), q): """Run a byCycle service.""" module_name = 'bycycle.core.service.{service}'.format(service=service) service_factory = load_object(module_name, 'Service') if service == 'route': q = re.split('\s+to\s+', q, re.I) if len(q) < 2: abort(1, 'Route must be specified as "A to B"') engine = get_engine() session_factory = get_session_factory(engine) session = session_factory() start_time = time.time() try: service = service_factory(session) response = service.query(q) except Exception: session.rollback() raise else: session.close() print(response) print('{:.2f} seconds'.format(time.time() - start_time))
def __init__(self, path, connection_args=None, session=None, quiet=False): self.path = Path(path).resolve() self.quiet = quiet if session: self.session = session else: engine = get_engine(**connection_args) session_factory = session or get_session_factory(engine) self.session = session_factory() self.engine = self.session.bind
def setUp(self): self.engine = get_engine() self.session_factory = get_session_factory(self.engine) self.session = self.session_factory()
def __init__(self, connection_args, clean=True): self.engine = get_engine(**connection_args) self.session_factory = get_session_factory(self.engine) self.clean = clean