# Path: data_model.py
# class StopLocation(GeoModel):
#     stopID       = db.StringProperty()
#     intersection = db.StringProperty()
#     direction    = db.StringProperty()
#     description  = db.StringProperty(multiline=True)
# 
# Path: data_model.py
# class StopLocationLoader(db.Model):
#     stopID       = db.StringProperty()
#     name         = db.StringProperty()
#     description  = db.StringProperty(multiline=True)
#     lat          = db.FloatProperty()
#     lon          = db.FloatProperty()
#     direction    = db.StringProperty()
# 
# Path: data_model.py
# class RouteListing(db.Model):
#     route        = db.StringProperty()
#     routeCode    = db.StringProperty()
#     direction    = db.StringProperty()
#     stopID       = db.StringProperty()
#     stopCode     = db.StringProperty()
#     scheduleURL  = db.StringProperty(indexed=False)
#     stopLocation = db.ReferenceProperty(StopLocation,collection_name="stops")
# 
# Path: data_model.py
# class RouteListingLoader(db.Model):
#     routeID       = db.StringProperty()
#     routeCode     = db.StringProperty()
#     direction     = db.StringProperty()
#     directionCode = db.StringProperty()
#     stopID        = db.StringProperty()
#     stopCode      = db.StringProperty()
# 
# Path: data_model.py
# class DestinationListing(db.Model):
#     id    = db.StringProperty()
#     label = db.StringProperty()


import logging
from google.appengine.api.taskqueue import Task
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.db import GeoPt
from google.appengine.ext.db import TransactionFailedError
from google.appengine.ext.db import Timeout
from google.appengine.runtime import DeadlineExceededError
from data_model import StopLocation
from data_model import StopLocationLoader
from data_model import RouteListing
from data_model import RouteListingLoader
from data_model import DestinationListing
                                'direction':s.direction,
                               })
            task.add('crawler')

        logging.debug('Finished spawning StopLocationLoader tasks!')
        self.response.out.write('done spawning porting tasks!')

## end PortStopsHandler

#
# This handler is the task handler for porting an individual GTFS stop
#
class PortStopTask(webapp.RequestHandler):
    def post(self):
        stop_list = []

        stopID = self.request.get('stopID')
        if len(stopID) == 1:
            stopID = "000" + stopID
        if len(stopID) == 2:
            stopID = "00" + stopID
        if len(stopID) == 3:
            stopID = "0" + stopID

        name        = self.request.get('name')
        description = self.request.get('description')
        lat         = self.request.get('lat')
        lon         = self.request.get('lon')
        direction   = self.request.get('direction')


# Path: data_model.py
# class StopLocation(GeoModel):
#     stopID       = db.StringProperty()
#     intersection = db.StringProperty()
#     direction    = db.StringProperty()
#     description  = db.StringProperty(multiline=True)
# 
# Path: data_model.py
# class StopLocationLoader(db.Model):
#     stopID       = db.StringProperty()
#     name         = db.StringProperty()
#     description  = db.StringProperty(multiline=True)
#     lat          = db.FloatProperty()
#     lon          = db.FloatProperty()
#     direction    = db.StringProperty()
# 
# Path: data_model.py
# class RouteListing(db.Model):
#     route        = db.StringProperty()
#     routeCode    = db.StringProperty()
#     direction    = db.StringProperty()
#     stopID       = db.StringProperty()
#     stopCode     = db.StringProperty()
#     scheduleURL  = db.StringProperty(indexed=False)
#     stopLocation = db.ReferenceProperty(StopLocation,collection_name="stops")
# 
# Path: data_model.py
# class RouteListingLoader(db.Model):
#     routeID       = db.StringProperty()
#     routeCode     = db.StringProperty()
#     direction     = db.StringProperty()
#     directionCode = db.StringProperty()
#     stopID        = db.StringProperty()
#     stopCode      = db.StringProperty()
# 
# Path: data_model.py
# class DestinationListing(db.Model):
#     id    = db.StringProperty()
#     label = db.StringProperty()


# Path: crawl/load_gtfs.py
import logging
from google.appengine.api.taskqueue import Task
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.db import GeoPt
from google.appengine.ext.db import TransactionFailedError
from google.appengine.ext.db import Timeout
from google.appengine.runtime import DeadlineExceededError
from data_model import StopLocation
from data_model import StopLocationLoader
from data_model import RouteListing
from data_model import RouteListingLoader
from data_model import DestinationListing

                                'direction':s.direction,
                               })
            task.add('crawler')

        logging.debug('Finished spawning StopLocationLoader tasks!')
        self.response.out.write('done spawning porting tasks!')

## end PortStopsHandler

#
# This handler is the task handler for porting an individual GTFS stop
#
class PortStopTask(webapp.RequestHandler):
    def post(self):
        stop_list = []

        stopID = self.request.get('stopID')
        if len(stopID) == 1:
            stopID = "000" + stopID
        if len(stopID) == 2:
            stopID = "00" + stopID
        if len(stopID) == 3:
            stopID = "0" + stopID

        name        = self.request.get('name')
        description = self.request.get('description')
        lat         = self.request.get('lat')
        lon         = self.request.get('lon')
        direction   = self.request.get('direction')


        s = StopLocation()