>>> from storage import *
>>> from StringIO import StringIO
>>> from moving import MovingObject, Point, TimeInterval, Trajectory, prepareSplines

>>> f = openCheck('non_existant_file.txt')
File non_existant_file.txt could not be opened.

>>> nonexistentFilename = "nonexistent"
>>> loadPrototypeMatchIndexesFromSqlite(nonexistentFilename)
DB Error: no such table: prototypes
[]
>>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature')
DB Error: no such table: positions
DB Error: no such table: velocities
[]
>>> from os import remove
>>> remove(nonexistentFilename)

>>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10))
>>> o1.num = 2
>>> o2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9))
>>> o2.num = 3
>>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature')
>>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature')
>>> objects[0].getNum() == o1.num
True
>>> objects[1].getNum() == o2.num
True
>>> o1.getTimeInterval() == objects[0].getTimeInterval()
True
>>> o2.getTimeInterval() == objects[1].getTimeInterval()
True
>>> o1.getVelocities() == objects[0].getVelocities()
True
>>> o2.getVelocities() == objects[1].getVelocities()
True
>>> o1.getPositions() == objects[0].getPositions()
True
>>> o2.getPositions() == objects[1].getPositions()
True
>>> align1 = Trajectory.fromPointList([Point(-1, 0), Point(20, 0)])
>>> align2 = Trajectory.fromPointList([Point(-9, -3), Point(6, 3)])
>>> align1.computeCumulativeDistances()
>>> align2.computeCumulativeDistances()
>>> prepareSplines([align1, align2])
>>> o1.projectCurvilinear([align1, align2])
>>> o2.projectCurvilinear([align1, align2])
>>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'curvilinear')
>>> addCurvilinearTrajectoriesFromSqlite('test.sqlite', {o.num: o for o in objects})
>>> o1.curvilinearPositions[3][:2] == objects[0].curvilinearPositions[3][:2]
True
>>> o1.curvilinearPositions[7][:2] == objects[0].curvilinearPositions[7][:2]
True
>>> [str(l) for l in o1.curvilinearPositions.getLanes()] == objects[0].curvilinearPositions.getLanes()
True
>>> o2.curvilinearPositions[2][:2] == objects[1].curvilinearPositions[2][:2]
True
>>> o2.curvilinearPositions[6][:2] == objects[1].curvilinearPositions[6][:2]
True
>>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes()
True
>>> remove('test.sqlite')

>>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf')
>>> readline(strio)
'sadlkfjsdlakjf'
>>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf')
>>> readline(strio, ['#'])
'sadlkfjsdlakjf'
>>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf')
>>> readline(strio, ['%'])
'# asdlfjasdlkj0'
>>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf')
>>> readline(strio, '%*$')
'# asdlfjasdlkj0'
>>> readline(strio, '%#')
'sadlkfjsdlakjf'
