Changeset 1160
- Timestamp:
- 01/12/09 15:59:46 (3 years ago)
- Files:
-
- 2 added
- 1 removed
- 53 modified
- 1 moved
-
Core/trunk/bycycle/__init__.py (added)
-
Core/trunk/bycycle/core/model/__init__.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/address.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/compass.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/data/integrator.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/db.py (modified) (2 diffs)
-
Core/trunk/bycycle/core/model/entities/__init__.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/entities/base.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/entities/public.py (modified) (3 diffs)
-
Core/trunk/bycycle/core/model/milwaukeewi/__init__.py (modified) (2 diffs)
-
Core/trunk/bycycle/core/model/milwaukeewi/bicycle.py (modified) (2 diffs)
-
Core/trunk/bycycle/core/model/milwaukeewi/data/__init__.py (modified) (2 diffs)
-
Core/trunk/bycycle/core/model/milwaukeewi/data/integrator.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/milwaukeewi/data/shp2sql.py (modified) (12 diffs)
-
Core/trunk/bycycle/core/model/portlandor/__init__.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/portlandor/bicycle.py (modified) (11 diffs)
-
Core/trunk/bycycle/core/model/portlandor/data/__init__.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/portlandor/data/integrator.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/regions.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/route.py (modified) (1 diff)
-
Core/trunk/bycycle/core/model/sttypes.py (modified) (1 diff)
-
Core/trunk/bycycle/core/scripts/cmd.py (moved) (moved from Core/trunk/bycycle/core/scripts/bycycle.py) (4 diffs, 1 prop)
-
Core/trunk/bycycle/core/scripts/integrate.py (modified) (4 diffs)
-
Core/trunk/bycycle/core/scripts/matrix.py (modified) (1 diff)
-
Core/trunk/bycycle/core/scripts/test_bycycle.py (modified) (2 diffs)
-
Core/trunk/bycycle/core/services/__init__.py (modified) (1 diff)
-
Core/trunk/bycycle/core/services/geocode.py (modified) (1 diff)
-
Core/trunk/bycycle/core/services/identify.py (modified) (1 diff)
-
Core/trunk/bycycle/core/services/normaddr.py (modified) (1 diff)
-
Core/trunk/bycycle/core/services/route.py (modified) (2 diffs)
-
Core/trunk/tests/test_gis.py (modified) (3 diffs)
-
Core/trunk/tests/test_model/test_address.py (modified) (4 diffs)
-
Core/trunk/tests/test_services/test_geocode.py (modified) (1 diff)
-
Core/trunk/tests/test_services/test_normaddr.py (modified) (1 diff)
-
Core/trunk/tests/test_services/test_route.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/__init__.py (added)
-
TripPlanner/trunk/bycycle/tripplanner/__init__.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/config/__init__.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/config/environment.py (modified) (2 diffs)
-
TripPlanner/trunk/bycycle/tripplanner/config/middleware.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/error.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/geocodes.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/regions.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/routes.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/services.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/controllers/template.py (modified) (2 diffs)
-
TripPlanner/trunk/bycycle/tripplanner/lib/base.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/models (deleted)
-
TripPlanner/trunk/bycycle/tripplanner/tests/__init__.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_geocodes.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_regions.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_routes.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_services.py (modified) (1 diff)
-
TripPlanner/trunk/bycycle/tripplanner/websetup.py (modified) (1 diff)
-
TripPlanner/trunk/development.ini (modified) (1 diff)
-
TripPlanner/trunk/setup.cfg (modified) (1 diff)
-
TripPlanner/trunk/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Core/trunk/bycycle/core/model/__init__.py
r1043 r1160 18 18 19 19 """ 20 from by Cycle import model_path21 from by Cycle.model.db import engine, connection, cursor, Session22 from by Cycle.model.entities import *23 from by Cycle.model.address import *20 from bycycle.core import model_path 21 from bycycle.core.model.db import engine, connection, cursor, Session 22 from bycycle.core.model.entities import * 23 from bycycle.core.model.address import * -
Core/trunk/bycycle/core/model/address.py
r1036 r1160 13 13 ############################################################################### 14 14 """Address classes.""" 15 from by Cycle.util import joinAttrs16 from by Cycle.model.point import Point17 from by Cycle.model.entities import StreetName, Place15 from bycycle.core.util import joinAttrs 16 from bycycle.core.model.point import Point 17 from bycycle.core.model.entities import StreetName, Place 18 18 19 19 __all__ = ['AddressError', 'Address', 'PostalAddress', 'EdgeAddress', -
Core/trunk/bycycle/core/model/compass.py
r463 r1160 11 11 # NO WARRANTY OF ANY KIND. 12 12 ############################################################################### 13 from by Cycle.util import swapKeysAndValues13 from bycycle.core.util import swapKeysAndValues 14 14 15 15 -
Core/trunk/bycycle/core/model/data/integrator.py
r1096 r1160 47 47 from sqlalchemy import func, select, text, and_, or_ 48 48 49 from by Cycle.util import meter50 from by Cycle import model_path51 from by Cycle.model import db52 from by Cycle.model.entities import base, public53 from by Cycle.model.sttypes import street_types_ftoa49 from bycycle.core.util import meter 50 from bycycle.core import model_path 51 from bycycle.core.model import db 52 from bycycle.core.model.entities import base, public 53 from bycycle.core.model.sttypes import street_types_ftoa 54 54 55 55 -
Core/trunk/bycycle/core/model/db.py
r1057 r1160 26 26 from sqlalchemy import MetaData, orm, create_engine 27 27 28 from by Cycle import model_path28 from bycycle.core import model_path 29 29 30 30 … … 225 225 if __name__ == '__main__': 226 226 import sys 227 from by Cycle import model227 from bycycle.core import model 228 228 try: 229 229 action = sys.argv[1] -
Core/trunk/bycycle/core/model/entities/__init__.py
r1034 r1160 1 from by Cycle.model.entities.base import *2 from by Cycle.model.entities.public import *1 from bycycle.core.model.entities.base import * 2 from bycycle.core.model.entities.public import * -
Core/trunk/bycycle/core/model/entities/base.py
r1155 r1160 30 30 import simplejson 31 31 32 from by Cycle.util import gis, joinAttrs33 from by Cycle.model.db import engine, metadata, Session34 from by Cycle.model.entities.util import cascade_arg32 from bycycle.core.util import gis, joinAttrs 33 from bycycle.core.model.db import engine, metadata, Session 34 from bycycle.core.model.entities.util import cascade_arg 35 35 36 36 -
Core/trunk/bycycle/core/model/entities/public.py
r1155 r1160 22 22 import pyproj 23 23 24 from by Cycle import model_path25 from by Cycle.util import gis, joinAttrs26 from by Cycle.model import db27 from by Cycle.model.entities import DeclarativeBase28 from by Cycle.model.entities.util import cascade_arg, encodeFloat29 from by Cycle.model.data.sqltypes import POINT24 from bycycle.core import model_path 25 from bycycle.core.util import gis, joinAttrs 26 from bycycle.core.model import db 27 from bycycle.core.model.entities import DeclarativeBase 28 from bycycle.core.model.entities.util import cascade_arg, encodeFloat 29 from bycycle.core.model.data.sqltypes import POINT 30 30 31 31 __all__ = [ … … 186 186 187 187 """ 188 from by Cycle.util.meter import Meter, Timer188 from bycycle.core.util.meter import Meter, Timer 189 189 190 190 timer = Timer() … … 249 249 module = getattr(self, '_module', None) 250 250 if module is None: 251 path = 'by Cycle.model.%s' % self.slug251 path = 'bycycle.core.model.%s' % self.slug 252 252 exec 'from %s import Node as _RegionNode' % path 253 253 exec 'from %s import Edge as _RegionEdge' % path -
Core/trunk/bycycle/core/model/milwaukeewi/__init__.py
r1155 r1160 12 12 # NO WARRANTY OF ANY KIND. 13 13 ############################################################################### 14 from sqlalchemy.types import Integer, String, CHAR, Integer 14 from sqlalchemy import Column, ForeignKey 15 from sqlalchemy.types import Integer, CHAR 15 16 16 from by Cycle.util import gis17 from by Cycle.model import db18 from by Cycle.model.entities import base19 from by Cycle.model.entities.util import encodeFloat20 from by Cycle.model.entities.base import base_statements21 from byCycle.model.data.sqltypes import POINT, LINESTRING 22 from byCycle.model.milwaukeewi.data import SRID, slug17 from bycycle.core.model import db 18 from bycycle.core.model.entities import base 19 from bycycle.core.model.entities.util import encodeFloat 20 from bycycle.core.model.data.sqltypes import POINT, LINESTRING 21 from bycycle.core.model.milwaukeewi.data import SRID, slug 22 23 from dijkstar import infinity 23 24 24 25 25 __all__ = [' Edge', 'Node', 'StreetName', 'City', 'State', 'Place']26 __all__ = ['MilwaukeeWINode', 'MilwaukeeWIEdge'] 26 27 27 28 28 class Edge(base.Edge): 29 base_statements('Edge') 30 has_field('geom', LINESTRING(SRID)) 31 has_field('code', CHAR(3)) 32 has_field('bikemode', CHAR(1)) # enum(t, r, l, p) 33 has_field('lanes', Integer) 34 has_field('adt', Integer) 35 has_field('spd', Integer) 36 37 @classmethod 38 def _adjustRowForMatrix(cls, row): 39 length = row.geom.length 40 return {'length': encodeFloat(length)} 29 table_args = dict(schema='milwaukeewi') 41 30 42 31 43 class Node(base.Node): 44 base_statements('Node') 45 has_field('geom', POINT(SRID)) 32 class MilwaukeeWINode(base.Node): 33 __tablename__ = 'nodes' 34 __table_args__ = table_args 35 __mapper_args__ = dict(polymorphic_identity='milwaukeewi_node') 36 37 id = Column(Integer, ForeignKey('public.nodes.id'), primary_key=True) 38 geom = Column(POINT(SRID)) 46 39 47 40 @property … … 49 42 return super(Node, self).edges 50 43 51 52 class StreetName(base.StreetName): 53 base_statements('StreetName') 44 Node = MilwaukeeWINode 54 45 55 46 56 class City(base.City): 57 base_statements('City') 47 class MilwaukeeWIEdge(base.Edge): 48 __tablename__ = 'edges' 49 __table_args__ = table_args 50 __mapper_args__ = dict(polymorphic_identity='milwaukeewi_edge') 58 51 52 id = Column('id', Integer, ForeignKey('public.edges.id'), primary_key=True) 53 geom = Column(LINESTRING(SRID)) 54 code = Column(CHAR(3)) 55 bikemode = Column(CHAR(1)) # enum(t, r, l, p) 56 lanes = Column(Integer) 57 adt = Column(Integer) 58 spd = Column(Integer) 59 59 60 class State(base.State): 61 base_statements('State') 60 @classmethod 61 def _adjustRowForMatrix(cls, row): 62 return {'length': encodeFloat(row.geom.length)} 62 63 63 64 class Place(base.Place): 65 base_statements('Place') 64 Edge = MilwaukeeWIEdge -
Core/trunk/bycycle/core/model/milwaukeewi/bicycle.py
r912 r1160 7 7 # Copyright (C) 2006, 2007 Wyatt Baldwin, byCycle.org <wyatt@bycycle.org>. 8 8 # All rights reserved. 9 # 9 # 10 10 # For terms of use and warranty details, please see the LICENSE file included 11 11 # in the top level of this distribution. This software is provided AS IS with … … 13 13 ############################################################################### 14 14 """Bicycle travel mode for Milwaukee, WI, region.""" 15 from by Cycle.model import tmode16 from by Cycle.model.entities.util import float_decode15 from bycycle.core.model import tmode 16 from bycycle.core.model.entities.util import float_decode 17 17 18 18 -
Core/trunk/bycycle/core/model/milwaukeewi/data/__init__.py
r1034 r1160 13 13 ############################################################################### 14 14 """This package contains everything to do with this region's data and DB.""" 15 from elixir import Entity, using_options, using_table_options 16 from elixir import has_field 17 from elixir import Integer, String, Integer, Float 15 from sqlalchemy import Column 16 from sqlalchemy.types import Integer, String, Integer, Float, Numeric 18 17 19 from byCycle.model import db 20 from byCycle.model.data.sqltypes import MULTILINESTRING 18 from bycycle.core.model import db 19 from bycycle.core.model.entities import DeclarativeBase 20 from bycycle.core.model.data.sqltypes import MULTILINESTRING 21 21 22 22 __all__ = ['title', 'slug', 'SRID', 'units', 'earth_circumference', … … 73 73 } 74 74 75 class Raw( Entity):76 using_options(tablename=slug)77 using_table_options(schema='raw')75 class Raw(DeclarativeBase): 76 __tablename__ = slug 77 __table_args__ = dict(schema='raw') 78 78 79 has_field('gid',Integer, primary_key=True, key='id')79 gid = Column(Integer, primary_key=True, key='id') 80 80 81 # To edge table (core) 82 has_field('the_geom', MULTILINESTRING(SRID), key='geom') 83 has_field('fnode', Integer, key='node_f_id') 84 has_field('tnode', Integer, key='node_t_id') 85 has_field('fraddl', Integer, key='addr_f_l') 86 has_field('toaddl', Integer, key='addr_t_l') 87 has_field('fraddr', Integer, key='addr_f_r') 88 has_field('toaddr', Integer, key='addr_t_r') 89 has_field('tlid', Float, key='permanent_id') 90 has_field('cfcc', Integer, key='code') 91 has_field('one_way', String(2)) 92 has_field('bike_facil', String(2), key='bikemode') 81 # TODO: Convert to SA declarative 82 ## To edge table (core) 83 #has_field('the_geom', MULTILINESTRING(SRID), key='geom') 84 #has_field('fnode', Integer, key='node_f_id') 85 #has_field('tnode', Integer, key='node_t_id') 86 #has_field('fraddl', Integer, key='addr_f_l') 87 #has_field('toaddl', Integer, key='addr_t_l') 88 #has_field('fraddr', Integer, key='addr_f_r') 89 #has_field('toaddr', Integer, key='addr_t_r') 90 #has_field('tlid', Float, key='permanent_id') 91 #has_field('cfcc', Integer, key='code') 92 #has_field('one_way', String(2)) 93 #has_field('bike_facil', String(2), key='bikemode') 93 94 94 # To street names table95 has_field('fedirp', String(2), key='prefix')96 has_field('fename', String(30), key='name')97 has_field('fetype', String(4), key='sttype')98 has_field('fedirs', String(2), key='suffix')95 ## To street names table 96 #has_field('fedirp', String(2), key='prefix') 97 #has_field('fename', String(30), key='name') 98 #has_field('fetype', String(4), key='sttype') 99 #has_field('fedirs', String(2), key='suffix') 99 100 100 # To cities table101 has_field('cityl', String(4), key='city_l')102 has_field('cityr', String(4), key='city_r')101 ## To cities table 102 #has_field('cityl', String(4), key='city_l') 103 #has_field('cityr', String(4), key='city_r') 103 104 104 # To places table105 has_field('zipl', Integer, key='zip_code_l')106 has_field('zipr', Integer, key='zip_code_r')105 ## To places table 106 #has_field('zipl', Integer, key='zip_code_l') 107 #has_field('zipr', Integer, key='zip_code_r') 107 108 108 # To edge table (supplemental)109 has_field('lanes', Integer)110 has_field('adt', Integer)111 has_field('spd', Integer)109 ## To edge table (supplemental) 110 #has_field('lanes', Integer) 111 #has_field('adt', Integer) 112 #has_field('spd', Integer) -
Core/trunk/bycycle/core/model/milwaukeewi/data/integrator.py
r1046 r1160 12 12 # NO WARRANTY OF ANY KIND. 13 13 ############################################################################### 14 from by Cycle.model.data import integrator15 from by Cycle.model import milwaukeewi16 from by Cycle.model.milwaukeewi import data14 from bycycle.core.model.data import integrator 15 from bycycle.core.model import milwaukeewi 16 from bycycle.core.model.milwaukeewi import data 17 17 18 18 -
Core/trunk/bycycle/core/model/milwaukeewi/data/shp2sql.py
r461 r1160 9 9 TERMS AND CONDITIONS FOR USE, MODIFICATION, DISTRIBUTION 10 10 11 1. The software may be used and modified by individuals for noncommercial, 11 1. The software may be used and modified by individuals for noncommercial, 12 12 private use. 13 13 14 14 2. The software may not be used for any commercial purpose. 15 15 16 3. The software may not be made available as a service to the public or within 16 3. The software may not be made available as a service to the public or within 17 17 any organization. 18 18 19 19 4. The software may not be redistributed. 20 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 32 32 """ 33 # shp2sql.py 33 # shp2sql.py 34 34 # Milwaukee, WI, shp/dbf import 35 # 36 # AUTHOR 35 # 36 # AUTHOR 37 37 # Wyatt Baldwin <wyatt@bycycle.org> 38 # DATE 38 # DATE 39 39 # January 27, 2006 40 40 # March 30, 2006 [Switched from SQLite to MySQL] 41 41 # April 4, 2006 [Converted to single-DB, shared with other regions] 42 # VERSION 42 # VERSION 43 43 # 0.1 44 # PURPOSE 44 # PURPOSE 45 45 # Script to import line geometry and associated attributes from a street layer 46 46 # shapefile into a normalized database 47 # USAGE 47 # USAGE 48 48 # python shp2sql.py 49 # LICENSE 49 # LICENSE 50 50 # GNU Public License (GPL) 51 51 # See LICENSE in top-level package directory 52 # WARRANTY 52 # WARRANTY 53 53 # This program comes with NO warranty, real or implied. 54 54 # TODO 55 55 # Turn this into a derived class; create a base class that all regions can use 56 56 import sys, os 57 from by Cycle.util import gis, meter57 from bycycle.core.util import gis, meter 58 58 59 59 … … 120 120 timer = None 121 121 122 122 123 123 def shpToRawSql(): 124 124 datasource = 'route_roads84psrenode' … … 138 138 if not _wait('Load SQL into DB'): 139 139 _system(cmd) 140 140 141 141 def addColumns(): 142 # Add missing... 142 # Add missing... 143 143 # INTEGER columns 144 144 Q = 'ALTER TABLE %s ADD COLUMN %%s %%s NOT NULL' % raw … … 177 177 cmd = 'mysql -u root --password="" < ./schema.sql' 178 178 _system(cmd) 179 179 180 180 def unifyAddressRanges(): 181 181 """Combine left and right side address number into a single value.""" … … 224 224 for row in db.fetchAll(): 225 225 stid = stnames[(row[1],row[2],row[3],row[4])] 226 if stid in stid_rawids: 226 if stid in stid_rawids: 227 227 stid_rawids[stid].append(row[0]) 228 else: 228 else: 229 229 stid_rawids[stid] = [row[0]] 230 230 # Iterate over street name IDs and set street name IDs of raw records … … 279 279 '(SELECT DISTINCT fnode, startpoint(geo)' \ 280 280 ' FROM %s)' % (region, raw) 281 _execute(Q) 281 _execute(Q) 282 282 Q = 'INSERT INTO %s_layer_node ' \ 283 283 '(SELECT DISTINCT tnode, endpoint(geo)' \ … … 314 314 """Set up DB connection.""" 315 315 global db 316 path = 'by Cycle.model.%s' % region316 path = 'bycycle.core.model.%s' % region 317 317 db = __import__(path, globals(), locals(), ['']).Mode() 318 318 319 319 def _execute(Q, show=True): 320 320 """Execute a SQL query.""" … … 331 331 def run(): 332 332 global start, only, no_prompt, timer 333 333 334 334 overall_timer = meter.Timer() 335 335 overall_timer.start() 336 336 337 337 # Reset for each function 338 timer = meter.Timer() 338 timer = meter.Timer() 339 339 timer.start() 340 340 … … 344 344 ('Add columns to raw', 345 345 addColumns), 346 346 347 347 ('Fix raw table: Remove NULLs, add columns, etc', 348 348 fixRaw), 349 349 350 350 ('Create byCycle schema tables', 351 351 createSchema), 352 352 353 353 ('Unify address ranges', 354 354 unifyAddressRanges), 355 355 356 356 ('Transfer street names', 357 357 transferStreetNames), 358 358 359 359 ('Update street name IDs in raw table', 360 360 updateRawStreetNameIds), 361 361 362 362 ('Transfer city names', 363 363 transferCityNames), 364 364 365 365 ('Update city IDs in raw table', 366 366 updateRawCityIds), 367 367 368 368 ('Update state IDs in raw table', 369 369 updateRawStateIds), 370 370 371 371 ('Create nodes', 372 372 createNodes), 373 373 374 374 ('Transfer attributes', 375 375 transferAttrs), … … 381 381 except IndexError: 382 382 pass 383 else: 383 else: 384 384 try: 385 385 start = int(arg1) … … 394 394 only = arg2 == 'only' 395 395 no_prompt = arg2 == 'no_prompt' 396 396 397 397 print 'Transferring data into byCycle schema...\n' \ 398 398 '----------------------------------------' \ … … 409 409 except IndexError: 410 410 args = () 411 # Do function 412 timer.start() 411 # Do function 412 timer.start() 413 413 apply(func, args) 414 414 print timer.stop() -
Core/trunk/bycycle/core/model/portlandor/__init__.py
r1155 r1160 15 15 from sqlalchemy.types import Unicode, Integer, String, CHAR, Integer, Numeric, Float 16 16 17 from by Cycle.model import db18 from by Cycle.model.entities import base19 from by Cycle.model.entities.util import encodeFloat20 from by Cycle.model.data.sqltypes import POINT, LINESTRING21 from by Cycle.model.portlandor.data import SRID, slug17 from bycycle.core.model import db 18 from bycycle.core.model.entities import base 19 from bycycle.core.model.entities.util import encodeFloat 20 from bycycle.core.model.data.sqltypes import POINT, LINESTRING 21 from bycycle.core.model.portlandor.data import SRID, slug 22 22 23 23 from dijkstar import infinity -
Core/trunk/bycycle/core/model/portlandor/bicycle.py
r918 r1160 6 6 # Copyright (C) 2006 Wyatt Baldwin, byCycle.org <wyatt@bycycle.org>. 7 7 # All rights reserved. 8 # 8 # 9 9 # For terms of use and warranty details, please see the LICENSE file included 10 10 # in the top level of this distribution. This software is provided AS IS with … … 12 12 ############################################################################### 13 13 """Bicycle travel mode for Portland, OR, region.""" 14 from by Cycle.model import tmode15 from by Cycle.model.entities.util import float_decode14 from bycycle.core.model import tmode 15 from bycycle.core.model.entities.util import float_decode 16 16 17 17 … … 33 33 """ 34 34 35 ``pref`` `string` 35 ``pref`` `string` 36 36 User's simple preference option. Can be empty or one of "default", 37 37 "flatter", "safer", "shorter", or "faster". … … 44 44 (0, 0.65, 1.8, 3.7, 7, 12, 21, 500)] 45 45 mph_up = (12.5, 11, 9.5, 7.5, 5, 3, 2.5, 2.5) 46 mph_down = (12.5, 14, 17, 21, 26, 31, 32, 32) 47 46 mph_down = (12.5, 14, 17, 21, 26, 31, 32, 32) 47 48 48 global edge_attrs_index, length_index, code_index, bikemode_index 49 49 global abs_slp_index, up_frac_index, node_f_id_index … … 55 55 abs_slp_index = edge_attrs_index['abs_slope'] 56 56 up_frac_index = edge_attrs_index['up_frac'] 57 node_f_id_index = edge_attrs_index['node_f_id'] 57 node_f_id_index = edge_attrs_index['node_f_id'] 58 58 street_name_id_index = edge_attrs_index['street_name_id'] 59 59 … … 92 92 lt = 1 93 93 mt = 1.17 94 ht = 1.33 94 ht = 1.33 95 95 ca = 2.67 96 96 cca = 10 … … 102 102 bca = 2 103 103 bcca = 3 104 bccca = 4 104 bccca = 4 105 105 # no bike mode 106 106 mult = 2 … … 111 111 no_bm_cca = bcca * mult 112 112 no_bm_ccca = bccca * mult 113 113 114 114 def getEdgeWeight(self, v, edge_attrs, prev_edge_attrs): 115 115 """Calculate weight for edge given it & last crossed edge's attrs.""" … … 124 124 125 125 # -- Calculate base weight of edge (in hours) 126 126 127 127 # Length of edge that is uphill in from => to direction 128 128 up_len = length * upfrac … … 179 179 elif 1200 <= code < 1300: hours *= bcca #ca+ 180 180 elif 1100 <= code < 1200: hours *= bccca #ca++ 181 else: hours *= xxx #? 181 else: hours *= xxx #? 182 182 elif bikemode == 'l': hours *= lt 183 183 elif bikemode == 'm': hours *= mt … … 206 206 hours += .0027777 # 10 seconds 207 207 except TypeError: 208 pass 208 pass 209 209 210 210 return hours -
Core/trunk/bycycle/core/model/portlandor/data/__init__.py
r1096 r1160 16 16 from sqlalchemy.types import Integer, String, Integer, Float, Numeric 17 17 18 from by Cycle.model import db19 from by Cycle.model.entities import DeclarativeBase20 from by Cycle.model.data.sqltypes import MULTILINESTRING18 from bycycle.core.model import db 19 from bycycle.core.model.entities import DeclarativeBase 20 from bycycle.core.model.data.sqltypes import MULTILINESTRING 21 21 22 22 from cities import cities_atof -
Core/trunk/bycycle/core/model/portlandor/data/integrator.py
r1046 r1160 12 12 # NO WARRANTY OF ANY KIND. 13 13 ############################################################################### 14 from by Cycle.model.data import integrator15 from by Cycle.model import portlandor16 from by Cycle.model.portlandor import data14 from bycycle.core.model.data import integrator 15 from bycycle.core.model import portlandor 16 from bycycle.core.model.portlandor import data 17 17 18 18 -
Core/trunk/bycycle/core/model/regions.py
r1034 r1160 17 17 18 18 """ 19 from by Cycle.model.entities import Region19 from bycycle.core.model.entities import Region 20 20 21 21 -
Core/trunk/bycycle/core/model/route.py
r1155 r1160 15 15 from shapely.geometry import LineString 16 16 17 from by Cycle.model import glineenc17 from bycycle.core.model import glineenc 18 18 19 19 __all__ = ['Route'] -
Core/trunk/bycycle/core/model/sttypes.py
r760 r1160 22 22 23 23 """ 24 from by Cycle.util import swapKeysAndValues24 from bycycle.core.util import swapKeysAndValues 25 25 26 26 -
Core/trunk/bycycle/core/scripts/cmd.py
r461 r1160 3 3 # Created: 2006-09-26 4 4 5 """ 6 Command-line interface to the byCycle library. 5 """Command-line interface to the byCycle library.""" 6 import sys 7 7 8 """ 9 import os 10 def __getbyCycleImportPath(level): 11 """Get path to dir containing the byCycle package this module is part of. 12 13 ``level`` `int` 14 How many levels up the dir containing the package is. 15 16 TODO: In Python 2.5 I think this just becomes 17 "from ...byCycle.model import <stuff>" or maybe 18 "from ..model import <stuff>" 19 20 """ 21 path = os.path.abspath(__file__) 22 opd = os.path.dirname 23 for i in range(level): 24 path = opd(path) 25 return path 26 27 import sys 28 sys.path.insert(0, __getbyCycleImportPath(3)) 29 from byCycle.model import regions 30 from byCycle.util import meter 8 from bycycle.core.model import regions 9 from bycycle.core.util import meter 31 10 32 11 33 import_path = 'by Cycle.services.%s'12 import_path = 'bycycle.core.services.%s' 34 13 35 14 services = { … … 40 19 41 20 errors = [] 42 21 43 22 timer = meter.Timer() 44 23 45 24 46 25 def main(argv): 47 26 checkForErrors() … … 52 31 addError('No service specified') 53 32 else: 54 if service in services:55 service = services[service]33 service = services[service] 34 path = import_path % service 56 35 try: 57 service_module = __import__(import_path % service, 58 globals(), locals(), ['']) 36 service_module = __import__(path, globals(), locals(), ['']) 59 37 except ImportError: 60 38 raise 61 addError('Unknown service "%s"' % service) 62 39 63 40 try: 64 41 q = argv[2] … … 98 75 sys.exit(2) 99 76 100 77 101 78 def usage(msgs=[]): 102 79 print 'Usage: bycycle.py ' \ -
Core/trunk/bycycle/core/scripts/integrate.py
r1057 r1160 21 21 22 22 shp2pgsql.py --region portlandor --source pirate --layer str06oct -n 23 23 24 24 In this example, --region is the region "key" matching the region's 25 25 Python module name and ``slug`` in the public.regions database table. 26 26 27 27 --source is the name of a directory in ${HOME}/byCycleData/portlandor. In 28 28 this case, on my machine, it refers to the directory 29 /home/bycycle/byCycleData/portlandor/pirate. 30 29 /home/bycycle/byCycleData/portlandor/pirate. 30 31 31 [Note that, for now, ${HOME}/byCycleData can't be changed from the command 32 32 line. It can be changed by creating an Integrator and setting its … … 51 51 The data source. This is a directory containing shapefiles. For now, 52 52 it is always relative to ${HOME}/byCycleData. REQUIRED. 53 54 --layer | -l <layer name> 53 54 --layer | -l <layer name> 55 55 The data layer. This is the base name for a shapefile and its related 56 56 files. For example, if the layer name is "str06oct", there will be 57 57 corresponding files named "str06oct.shp", "str06oct.dbf", etc. 58 58 REQUIRED. 59 59 60 60 --start | -s <index> 61 61 The index (0-based) of the action to start from. Yes, this is clunky 62 62 in that we need to know the index number for an action--a menu system 63 63 should be created. Defaults to 0. 64 64 65 65 --end | -e <index> 66 66 Like --start but for the last action that should be run. Defaults to 67 67 one less than the number of actions. 68 68 69 69 --no-prompt | -n 70 70 Run the actions from --start to --end without prompting. The default 71 71 is to prompt for every action. 72 72 73 73 --only | -o <index> 74 Do just the action indicated by ``index``, without prompting. By 74 Do just the action indicated by ``index``, without prompting. By 75 75 default, this isn't used. 76 76 77 77 If no args are supplied, the default is to prompt for all actions. 78 78 … … 86 86 87 87 88 def main(argv): 88 def main(argv): 89 89 # Get command line options 90 90 opts = getOpts(sys.argv[1:]) … … 94 94 layer = opts.pop('layer') 95 95 no_prompt = bool(opts.get('no_prompt', opts.get('only', False))) 96 97 imp_path = 'by Cycle.model.%s.data.integrator' % region96 97 imp_path = 'bycycle.core.model.%s.data.integrator' % region 98 98 integrator_module = __import__(imp_path, locals(), globals(), ['']) 99 99 -
Core/trunk/bycycle/core/scripts/matrix.py
r791 r1160 2 2 """Create adjacency matrix for region given as first arg on command line.""" 3 3 import sys 4 from by Cycle.model import Region4 from bycycle.core.model import Region 5 5 6 6 no_region_msg = ('Specify a region name. Use "all" to create matrices for ' -
Core/trunk/bycycle/core/scripts/test_bycycle.py
r187 r1160 9 9 TERMS AND CONDITIONS FOR USE, MODIFICATION, DISTRIBUTION 10 10 11 1. The software may be used and modified by individuals for noncommercial, 11 1. The software may be used and modified by individuals for noncommercial, 12 12 private use. 13 13 14 14 2. The software may not be used for any commercial purpose. 15 15 16 3. The software may not be made available as a service to the public or within 16 3. The software may not be made available as a service to the public or within 17 17 any organization. 18 18 19 19 4. The software may not be redistributed. 20 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 32 32 """ 33 import bycycle 33 from bycycle.core.scripts import cmd 34 35 34 36 if __name__ == '__main__': 35 37 args_list = ( … … 39 41 for args in args_list: 40 42 argv = [a.strip() for a in args.split(';')] 41 bycycle.main(argv)43 cmd.main(argv) -
Core/trunk/bycycle/core/services/__init__.py
r1070 r1160 13 13 ################################################################################ 14 14 """Provides a base class for the byCycle core services.""" 15 from by Cycle.model import regions16 from by Cycle.model import db15 from bycycle.core.model import regions 16 from bycycle.core.model import db 17 17 18 18 -
Core/trunk/bycycle/core/services/geocode.py
r1070 r1160 34 34 from sqlalchemy.orm.exc import NoResultFound 35 35 36 from by Cycle.model import db37 from by Cycle.model import StreetName, City, State, Place38 from by Cycle.model.address import *39 from by Cycle.model.geocode import *40 41 from by Cycle import services42 from by Cycle.services import normaddr, identify43 from by Cycle.services.exceptions import *36 from bycycle.core.model import db 37 from bycycle.core.model import StreetName, City, State, Place 38 from bycycle.core.model.address import * 39 from bycycle.core.model.geocode import * 40 41 from bycycle.core import services 42 from bycycle.core.services import normaddr, identify 43 from bycycle.core.services.exceptions import * 44 44 45 45 -
Core/trunk/bycycle/core/services/identify.py
r1070 r1160 20 20 from sqlalchemy.orm.exc import NoResultFound 21 21 22 from by Cycle.model import db23 from by Cycle.model.point import Point24 from by Cycle import services25 from by Cycle.services.exceptions import IdentifyError22 from bycycle.core.model import db 23 from bycycle.core.model.point import Point 24 from bycycle.core import services 25 from bycycle.core.services.exceptions import IdentifyError 26 26 27 27 -
Core/trunk/bycycle/core/services/normaddr.py
r1070 r1160 29 29 """ 30 30 import re 31 from by Cycle import services32 from by Cycle.services.exceptions import ByCycleError, InputError33 from by Cycle.model import db34 from by Cycle.model import address, regions, states, sttypes, compass35 from by Cycle.model.entities import StreetName, Place31 from bycycle.core import services 32 from bycycle.core.services.exceptions import ByCycleError, InputError 33 from bycycle.core.model import db 34 from bycycle.core.model import address, regions, states, sttypes, compass 35 from bycycle.core.model.entities import StreetName, Place 36 36 37 37 -
Core/trunk/bycycle/core/services/route.py
r1155 r1160 47 47 from shapely.geometry import Point, LineString 48 48 49 from by Cycle.util import gis50 51 from by Cycle.model.address import *52 from by Cycle.model.geocode import *53 from by Cycle.model.route import *54 55 from by Cycle import services56 from by Cycle.services import geocode57 from by Cycle.services.exceptions import ByCycleError, InputError, NotFoundError49 from bycycle.core.util import gis 50 51 from bycycle.core.model.address import * 52 from bycycle.core.model.geocode import * 53 from bycycle.core.model.route import * 54 55 from bycycle.core import services 56 from bycycle.core.services import geocode 57 from bycycle.core.services.exceptions import ByCycleError, InputError, NotFoundError 58 58 59 59 … … 148 148 149 149 # Get weight function for specified travel mode 150 path = 'by Cycle.model.%s.%s' % (self.region.slug, tmode)150 path = 'bycycle.core.model.%s.%s' % (self.region.slug, tmode) 151 151 module = __import__(path, globals(), locals(), ['']) 152 152 mode = module.TravelMode(self.region, pref=pref) -
Core/trunk/tests/test_gis.py
r855 r1160 9 9 TERMS AND CONDITIONS FOR USE, MODIFICATION, DISTRIBUTION 10 10 11 1. The software may be used and modified by individuals for noncommercial, 11 1. The software may be used and modified by individuals for noncommercial, 12 12 private use. 13 13 14 14 2. The software may not be used for any commercial purpose. 15 15 16 3. The software may not be made available as a service to the public or within 16 3. The software may not be made available as a service to the public or within 17 17 any organization. 18 18 19 19 4. The software may not be redistributed. 20 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 31 32 32 """ 33 33 import unittest 34 from by Cycle.util.gis import *34 from bycycle.core.util.gis import * 35 35 36 36 … … 38 38 def testTuple(self): 39 39 p = Point((-122.0, 45.0)) 40 40 41 41 def testWKTGeometry(self): 42 42 p = Point('point (1 2)') 43 43 44 44 def testEvalAsTuple(self): 45 45 p = Point("('-122.0', '45.0')") 46 46 47 47 def testTupleOfStrings(self): 48 48 p = Point(('-122.0', '45.0')) 49 49 50 50 def testTupleOfFloats(self): 51 51 p = Point((-122.0, 45.0)) 52 52 p = Point((-122, 45)) 53 53 54 54 def testClonePoint(self): 55 55 p = Point(Point(x=123, y=45)) 56 56 57 57 def testXYFloat(self): 58 58 p = Point(x=-122.0, y=45.0) 59 59 p = Point(x=-122, y=45) 60 60 61 61 def testXYString(self): 62 62 p = Point(x='-122', y='45') 63 63 64 64 def testXYPreferred(self): 65 65 p = Point(x_y='Blarg!', x=-123, y=45) 66 66 self.assertEqual(p.x, -123) 67 67 self.assertEqual(p.y, 45) 68 68 69 69 def testNoArgs(self): 70 70 p = Point() … … 88 88 lPoints = importWktGeometry(sPoints) 89 89 checkPoints(lPoints) 90 90 91 91 def testImportPoint(self): 92 92 def checkPoint(point): -
Core/trunk/tests/test_model/test_address.py
r856 r1160 16 16 """ 17 17 import unittest 18 from by Cycle.model.address import *19 from by Cycle.model.entities import *18 from bycycle.core.model.address import * 19 from bycycle.core.model.entities import * 20 20 21 21 … … 80 80 sAddr = 'SE Kelly St & SE 49th Ave\nPortland, OR 97206' 81 81 assert(str(oAddr) == sAddr) 82 82 83 83 84 84 class TestPointAddress(unittest.TestCase): 85 85 """Test creation of `PointAddress`es.""" 86 86 87 87 def test_WKT(self): 88 88 oAddr = PointAddress(x=-123.12, y=45) 89 89 self.assertEqual(str(oAddr), 'POINT (-123.120000 45.000000)') 90 90 91 91 def test_Eval(self): 92 92 oAddr = PointAddress(point='(-123.12, 45)') … … 94 94 oAddr = PointAddress(point='{"x": -123.12, "y": 45}') 95 95 self.assertEqual(str(oAddr), 'POINT (-123.120000 45.000000)') 96 96 97 97 def test_Kwargs(self): 98 98 oAddr = PointAddress(point='x=-123.12, y=45') … … 112 112 def test_Sequence(self): 113 113 oAddr = PointAddress(point=(-123.12, 45)) 114 self.assertEqual(str(oAddr), 'POINT (-123.120000 45.000000)') 115 116 114 self.assertEqual(str(oAddr), 'POINT (-123.120000 45.000000)') 115 116 117 117 if __name__ == "__main__": 118 118 unittest.main() -
Core/trunk/tests/test_services/test_geocode.py
r1071 r1160 13 13 ################################################################################ 14 14 import unittest 15 from by Cycle.util import meter16 from by Cycle.model import StreetName17 from by Cycle.model.geocode import *18 from by Cycle.services.geocode import *15 from bycycle.core.util import meter 16 from bycycle.core.model import StreetName 17 from bycycle.core.model.geocode import * 18 from bycycle.core.services.geocode import * 19 19 20 20 -
Core/trunk/tests/test_services/test_normaddr.py
r1046 r1160 13 13 ################################################################################ 14 14 import unittest 15 from by Cycle.services.normaddr import *16 from by Cycle.model import address, db17 from by Cycle.model.entities import Region, StreetName15 from bycycle.core.services.normaddr import * 16 from bycycle.core.model import address, db 17 from bycycle.core.model.entities import Region, StreetName 18 18 from sqlalchemy import * 19 19 -
Core/trunk/tests/test_services/test_route.py
r1072 r1160 14 14 import unittest 15 15 16 from by Cycle.services.route import *17 from by Cycle.model.route import Route16 from bycycle.core.services.route import * 17 from bycycle.core.model.route import Route 18 18 19 19 -
TripPlanner/trunk/bycycle/tripplanner/__init__.py
r222 r1160 1 """ 2 tripplanner 3 4 This file loads the finished app from tripplanner.config.middleware. 5 6 """ 7 8 from tripplanner.config.middleware import make_app 1 from bycycle.tripplanner.config.middleware import make_app -
TripPlanner/trunk/bycycle/tripplanner/config/__init__.py
r501 r1160 1 # 1 -
TripPlanner/trunk/bycycle/tripplanner/config/environment.py
r1035 r1160 5 5 from mako.lookup import TemplateLookup 6 6 7 from tripplanner.config.routing import make_map7 from bycycle.tripplanner.config.routing import make_map 8 8 9 import tripplanner.lib.app_globals as app_globals10 import tripplanner.lib.helpers11 from tripplanner.config.routing import make_map9 from bycycle.tripplanner.lib.app_globals import Globals 10 import bycycle.tripplanner.lib.helpers 11 from bycycle.tripplanner.config.routing import make_map 12 12 13 13 … … 22 22 23 23 # Initialize config with the basic options 24 config.init_app(global_conf, app_conf, package='tripplanner', paths=paths) 24 config.init_app( 25 global_conf, app_conf, package='bycycle.tripplanner', paths=paths) 25 26 26 27 # The following template options are passed to your template engines 27 28 config['routes.map'] = make_map() 28 config['pylons.app_globals'] = app_globals.Globals()29 config['pylons.h'] = tripplanner.lib.helpers29 config['pylons.app_globals'] = Globals() 30 config['pylons.h'] = bycycle.tripplanner.lib.helpers 30 31 31 32 # Create the Mako TemplateLookup, with the default auto-escaping -
TripPlanner/trunk/bycycle/tripplanner/config/middleware.py
r1132 r1160 11 11 from routes.middleware import RoutesMiddleware 12 12 13 from tripplanner.config.environment import load_environment14 from tripplanner.lib.middleware import RedirectMiddleware13 from bycycle.tripplanner.config.environment import load_environment 14 from bycycle.tripplanner.lib.middleware import RedirectMiddleware 15 15 16 16 -
TripPlanner/trunk/bycycle/tripplanner/controllers/error.py
r1037 r1160 12 12 from webhelpers.html.builder import literal 13 13 14 from tripplanner.lib.base import BaseController14 from bycycle.tripplanner.lib.base import BaseController 15 15 16 16 -
TripPlanner/trunk/bycycle/tripplanner/controllers/geocodes.py
r1122 r1160 1 from by Cycle.services.geocode import Service, MultipleMatchingAddressesError1 from bycycle.core.services.geocode import Service, MultipleMatchingAddressesError 2 2 3 from tripplanner.controllers.services import *3 from bycycle.tripplanner.controllers.services import * 4 4 5 5 -
TripPlanner/trunk/bycycle/tripplanner/controllers/regions.py
r1151 r1160 1 from by Cycle.services.exceptions import InputError, NotFoundError2 from by Cycle.model import regions3 from by Cycle.model.entities.public import Region1 from bycycle.core.services.exceptions import InputError, NotFoundError 2 from bycycle.core.model import regions 3 from bycycle.core.model.entities.public import Region 4 4 5 from tripplanner.lib.base import *5 from bycycle.tripplanner.lib.base import * 6 6 7 7 -
TripPlanner/trunk/bycycle/tripplanner/controllers/routes.py
r1122 r1160 1 from by Cycle.services.exceptions import InputError2 from by Cycle.services.route import Service, MultipleMatchingAddressesError1 from bycycle.core.services.exceptions import InputError 2 from bycycle.core.services.route import Service, MultipleMatchingAddressesError 3 3 4 from tripplanner.controllers.services import *4 from bycycle.tripplanner.controllers.services import * 5 5 6 6 -
TripPlanner/trunk/bycycle/tripplanner/controllers/services.py
r1142 r1160 5 5 import simplejson 6 6 7 from by Cycle.services.exceptions import *8 from by Cycle.model.geocode import Geocode9 10 from tripplanner.lib.base import *11 from tripplanner.lib.base import __all__ as base__all__12 from tripplanner.controllers.regions import RegionsController7 from bycycle.core.services.exceptions import * 8 from bycycle.core.model.geocode import Geocode 9 10 from bycycle.tripplanner.lib.base import * 11 from bycycle.tripplanner.lib.base import __all__ as base__all__ 12 from bycycle.tripplanner.controllers.regions import RegionsController 13 13 14 14 __all__ = base__all__ + ['ServicesController'] -
TripPlanner/trunk/bycycle/tripplanner/controllers/template.py
r501 r1160 1 from tripplanner.lib.base import *1 from bycycle.tripplanner.lib.base import * 2 2 3 3 class TemplateController(BaseController): 4 4 def view(self, url): 5 5 """ 6 This is the last place which is tried during a request to try to find a 6 This is the last place which is tried during a request to try to find a 7 7 file to serve. It could be used for example to display a template:: 8 8 9 9 def view(self, url): 10 10 return render_response(url) 11 11 12 12 Or, if you're using Myghty and would like to catch the component not 13 13 found error which will occur when the template doesn't exist; you 14 14 can use the following version which will provide a 404 if the template 15 15 doesn't exist:: 16 16 17 17 import myghty.exception 18 18 19 19 def view(self, url): 20 20 try: … … 22 22 except myghty.exception.ComponentNotFound: 23 23 return Response(code=404) 24 24 25 25 The default is just to abort the request with a 404 File not found 26 26 status message. -
TripPlanner/trunk/bycycle/tripplanner/lib/base.py
r1067 r1160 8 8 import restler as _restler 9 9 10 from by Cycle import model10 from bycycle.core import model 11 11 12 import tripplanner.lib.helpers as h12 import bycycle.tripplanner.lib.helpers as h 13 13 14 14 -
TripPlanner/trunk/bycycle/tripplanner/tests/__init__.py
r501 r1160 1 import os 2 import sys 1 """Pylons application test package 2 3 This package assumes the Pylons environment is already loaded, such as 4 when this script is imported from the `nosetests --with-pylons=test.ini` 5 command. 6 7 This module initializes the application via ``websetup`` (`paster 8 setup-app`) and provides the base testing objects. 9 """ 3 10 from unittest import TestCase 4 11 5 here_dir = os.path.dirname(os.path.abspath(__file__)) 6 conf_dir = os.path.dirname(os.path.dirname(here_dir)) 12 from paste.deploy import loadapp 13 from paste.fixture import TestApp 14 from paste.script.appinstall import SetupCommand 7 15 8 sys.path.insert(0, conf_dir) 16 from pylons import config, url 9 17 10 import pkg_resources 18 from routes import url_for 19 from routes.util import URLGenerator 11 20 12 pkg_resources.working_set.add_entry(conf_dir) 21 import pylons.test 13 22 14 pkg_resources.require('Paste') 15 pkg_resources.require('PasteScript') 23 __all__ = ['environ', 'url', 'url_for', 'TestController'] 16 24 17 from paste.deploy import loadapp, CONFIG 18 import paste.deploy 19 import paste.fixture 20 import paste.script.appinstall 25 # Invoke websetup with the current config file 26 SetupCommand('setup-app').run([config['__file__']]) 21 27 22 from tripplanner.config.routing import * 23 from routes import request_config, url_for 24 25 test_file = os.path.join(conf_dir, 'test.ini') 26 conf = paste.deploy.appconfig('config:' + test_file) 27 CONFIG.push_process_config({'app_conf': conf.local_conf, 28 'global_conf': conf.global_conf}) 29 30 cmd = paste.script.appinstall.SetupCommand('setup-app') 31 cmd.run([test_file]) 28 environ = {} 32 29 33 30 class TestController(TestCase): 34 def __init__(self, *args):35 wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)36 self.app = paste.fixture.TestApp(wsgiapp)37 TestCase.__init__(self, *args)38 31 39 __all__ = ['url_for', 'TestController'] 32 def __init__(self, *args, **kwargs): 33 if pylons.test.pylonsapp: 34 wsgiapp = pylons.test.pylonsapp 35 else: 36 wsgiapp = loadapp('config:%s' % config['__file__']) 37 self.app = TestApp(wsgiapp) 38 url._push_object(URLGenerator(config['routes.map'], environ)) 39 TestCase.__init__(self, *args, **kwargs) -
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_geocodes.py
r1067 r1160 1 1 import paste.fixture 2 from tripplanner.tests import *2 from bycycle.tripplanner.tests import * 3 3 4 4 class TestGeocodesController(TestController): -
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_regions.py
r638 r1160 1 from tripplanner.tests import *1 from bycycle.tripplanner.tests import * 2 2 3 3 class TestRegionsController(TestController): -
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_routes.py
r1067 r1160 1 from tripplanner.tests import *1 from bycycle.tripplanner.tests import * 2 2 3 3 class TestRouteController(TestController): -
TripPlanner/trunk/bycycle/tripplanner/tests/functional/test_services.py
r1023 r1160 1 from tripplanner.tests import *1 from bycycle.tripplanner.tests import * 2 2 3 3 class TestServiceController(TestController): -
TripPlanner/trunk/bycycle/tripplanner/websetup.py
r617 r1160 1 1 import paste.deploy 2 from by Cycle import model2 from bycycle.core import model 3 3 4 4 -
TripPlanner/trunk/development.ini
r1065 r1160 46 46 level = DEBUG 47 47 handlers = 48 qualname = acehotel48 qualname = tripplanner 49 49 50 50 [logger_sqlalchemy] -
TripPlanner/trunk/setup.cfg
r502 r1160 3 3 tag_svn_revision = true 4 4 5 #[easy_install]6 #find_links = http://www.pylonshq.com/download/5 [easy_install] 6 find_links = http://www.pylonshq.com/download/ 7 7 8 [pudge] 9 theme = pythonpaste.org 10 11 # Add extra doc files here with spaces between them 12 docs = tripplanner/docs/index.txt 13 14 # Doc Settings 15 doc_base = tripplanner/docs/ 16 dest = tripplanner/docs/html 17 18 # Add extra modules here separated with commas 19 modules = tripplanner 20 title = byCycleTripPlanner 21 organization = byCycle.org 22 23 # Optionally add extra links 24 organization_url = http://byCycle.org/ 25 trac_url=http://trac.bycycle.org/ 26 settings = no_about=true 27 28 [publish] 29 doc-dir=tripplanner/docs/html 30 make-dirs=1 8 [nosetests] 9 with-pylons = test.ini 10 with-doctest = true -
TripPlanner/trunk/setup.py
r1155 r1160 51 51 ), 52 52 test_suite = 'nose.collector', 53 package_data={' tripplanner': ['i18n/*/LC_MESSAGES/*.mo']},53 package_data={'bycycle.tripplanner': ['i18n/*/LC_MESSAGES/*.mo']}, 54 54 entry_points=""" 55 55 [paste.app_factory] 56 main= tripplanner:make_app56 main=bycycle.tripplanner:make_app 57 57 58 58 [paste.app_install]