Skip to content
Permalink
Browse files

resolved merge conflicts

  • Loading branch information...
Ben Fields
Ben Fields committed Feb 19, 2019
2 parents 067e02a + 1c7f8c0 commit 0c6f82d19da6b9f716d8297bb712ab5ffd3a580c
Showing with 493 additions and 287 deletions.
  1. +8 −7 examples/filter_unused_stops.py
  2. +3 −2 examples/google_random_queries.py
  3. +1 −1 examples/shuttle_from_xmlfeed.py
  4. +3 −2 examples/table.py
  5. +6 −5 extensions/googletransit/__init__.py
  6. +3 −1 extensions/googletransit/agency.py
  7. +2 −1 extensions/googletransit/extension_util.py
  8. +2 −1 extensions/googletransit/pybcp47/__init__.py
  9. +3 −2 extensions/googletransit/pybcp47/bcp47languageparser.py
  10. +3 −2 extensions/googletransit/pybcp47/testpybcp47.py
  11. +7 −5 extensions/googletransit/setup_extension.py
  12. +1 −1 extensions/googletransit/stop.py
  13. +11 −10 feedvalidator_ride.py
  14. +2 −1 gtfsscheduleviewer/marey_graph.py
  15. +2 −1 kmlparser.py
  16. +6 −5 kmlwriter.py
  17. +3 −2 location_editor.py
  18. +13 −12 merge.py
  19. +7 −6 misc/find_pytz_transition_times.py
  20. +9 −8 misc/import_ch_zurich.py
  21. +10 −9 misc/sql_loop.py
  22. +18 −18 misc/traceplus.py
  23. +26 −0 misc/traceplus_example.py
  24. +68 −0 misc/traceplusunittest.py
  25. +18 −0 misc/traceplusunittest_example.py
  26. +8 −7 schedule_viewer.py
  27. +1 −1 setup.py
  28. +15 −14 shape_importer.py
  29. +1 −1 tests/testexamples.py
  30. +1 −1 tests/testkmlwriter.py
  31. +4 −3 tests/testmerge.py
  32. +3 −2 tests/testshapelib.py
  33. +6 −6 tests/transitfeed/testloader.py
  34. +5 −5 tests/transitfeed/testschedule.py
  35. +13 −0 tests/transitfeed/testschedule_write.py
  36. +1 −1 tests/transitfeed/teststop.py
  37. +2 −2 tests/transitfeed/testtrip.py
  38. +3 −2 tests/util.py
  39. +22 −21 transitfeed/__init__.py
  40. +4 −3 transitfeed/agency.py
  41. +27 −0 transitfeed/errors.py
  42. +4 −3 transitfeed/fareattribute.py
  43. +3 −2 transitfeed/farerule.py
  44. +3 −2 transitfeed/frequency.py
  45. +23 −21 transitfeed/gtfsfactory.py
  46. +2 −1 transitfeed/gtfsfactoryuser.py
  47. +2 −1 transitfeed/gtfsobjectbase.py
  48. +7 −6 transitfeed/loader.py
  49. +7 −16 transitfeed/problems.py
  50. +4 −3 transitfeed/route.py
  51. +19 −6 transitfeed/schedule.py
  52. +3 −2 transitfeed/serviceperiod.py
  53. +4 −3 transitfeed/shape.py
  54. +8 −7 transitfeed/shapelib.py
  55. +2 −1 transitfeed/shapeloader.py
  56. +4 −3 transitfeed/shapepoint.py
  57. +4 −3 transitfeed/stop.py
  58. +5 −3 transitfeed/stoptime.py
  59. +4 −3 transitfeed/transfer.py
  60. +10 −5 transitfeed/trip.py
  61. +20 −22 transitfeed/util.py
  62. +1 −1 transitfeed/version.py
  63. +3 −2 unusual_trip_filter.py
@@ -16,6 +16,7 @@


"""Filter the unused stops out of a transit feed file."""
from __future__ import print_function

import optparse
import sys
@@ -32,29 +33,29 @@ def main():
help="Print removed stops to stdout")
(options, args) = parser.parse_args()
if len(args) != 2:
print >>sys.stderr, parser.format_help()
print >>sys.stderr, "\n\nYou must provide input_feed and output_feed\n\n"
print(parser.format_help(), file=sys.stderr)
print("\n\nYou must provide input_feed and output_feed\n\n", file=sys.stderr)
sys.exit(2)
input_path = args[0]
output_path = args[1]

loader = transitfeed.Loader(input_path)
schedule = loader.Load()

print "Removing unused stops..."
print("Removing unused stops...")
removed = 0
for stop_id, stop in schedule.stops.items():
if not stop.GetTrips(schedule):
removed += 1
del schedule.stops[stop_id]
if options.list_removed:
print "Removing %s (%s)" % (stop_id, stop.stop_name)
print("Removing %s (%s)" % (stop_id, stop.stop_name))
if removed == 0:
print "No unused stops."
print("No unused stops.")
elif removed == 1:
print "Removed 1 stop"
print("Removed 1 stop")
else:
print "Removed %d stops" % removed
print("Removed %d stops" % removed)

schedule.WriteGoogleTransitFeed(output_path)

@@ -23,6 +23,7 @@
look at the time of each leg. Also check the route names and headsigns are
formatted correctly and not redundant.
"""
from __future__ import print_function

from datetime import datetime
from datetime import timedelta
@@ -209,8 +210,8 @@ def main():
parser.set_defaults(output="google_random_queries.html", limit=50)
(options, args) = parser.parse_args()
if len(args) != 1:
print >>sys.stderr, parser.format_help()
print >>sys.stderr, "\n\nYou must provide the path of a single feed\n\n"
print(parser.format_help(), file=sys.stderr)
print("\n\nYou must provide the path of a single feed\n\n", file=sys.stderr)
sys.exit(2)
feed_path = args[0]

@@ -28,7 +28,7 @@

try:
import xml.etree.ElementTree as ET # python 2.5
except ImportError, e:
except ImportError as e:
import elementtree.ElementTree as ET # older pythons


@@ -32,6 +32,7 @@
# This is very simple example which you could use as a base for your own
# transit feed builder.

from __future__ import print_function
import transitfeed
from optparse import OptionParser
import re
@@ -49,7 +50,7 @@ def AddRouteToSchedule(schedule, table):
r = schedule.AddRoute(short_name=table[0][0], long_name=table[0][1], route_type='Bus')
for trip in table[2:]:
if len(trip) > len(table[1]):
print "ignoring %s" % trip[len(table[1]):]
print("ignoring %s" % trip[len(table[1]):])
trip = trip[0:len(table[1])]
t = r.AddTrip(schedule, headsign='My headsign')
trip_stops = [] # Build a list of (time, stopname) tuples
@@ -112,7 +113,7 @@ def ProcessOptions(schedule, table):
agency_timezone = row[1]

if not (agency_name and agency_url and agency_timezone):
print "You must provide agency information"
print("You must provide agency information")

schedule.NewDefaultAgency(agency_name=agency_name, agency_url=agency_url,
agency_timezone=agency_timezone)
@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from agency import *
from fareattribute import *
from route import *
from setup_extension import *
from stop import *
from __future__ import absolute_import
from .agency import *
from .fareattribute import *
from .route import *
from .setup_extension import *
from .stop import *
@@ -14,7 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import extension_util
from __future__ import absolute_import

from . import extension_util
import transitfeed

class Agency(transitfeed.Agency):
@@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pybcp47 import Bcp47LanguageParser
from __future__ import absolute_import
from .pybcp47 import Bcp47LanguageParser
from transitfeed import problems as problems_class
from transitfeed import util

@@ -14,4 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from bcp47languageparser import *
from __future__ import absolute_import
from .bcp47languageparser import *
@@ -19,6 +19,7 @@
from pkg_resources import resource_string
import re
import string
from functools import reduce

class FileParseError(Exception):
"""Exception raised for errors in the subtag registry file. """
@@ -74,11 +75,11 @@ def _ReadLanguageSubtagRegistryFile(self):
# Load the entries from the registry file in this package.
line_iterator = self._GetLinesFromLanguageSubtagRegistryFile()
# Read the header lines with the File-Date record.
first_line, line_number = line_iterator.next()
first_line, line_number = next(line_iterator)
if not first_line[:11] == 'File-Date: ':
raise FileParseError(line_number,
"Invalid first line '%s'! Must be a File-Date record." % (first_line))
second_line, line_number = line_iterator.next()
second_line, line_number = next(line_iterator)
if not second_line == '%%':
raise FileParseError(line_number,
"Invalid first record '%s'! Must start with '%%%%'." % (second_line))
@@ -16,11 +16,12 @@

# Unit tests for the bcp47languageparser module.

from __future__ import absolute_import
import codecs
import os
import unittest

from bcp47languageparser import Bcp47LanguageParser
from .bcp47languageparser import Bcp47LanguageParser

class PyBcp47TestCase(unittest.TestCase):
bcp47parser = Bcp47LanguageParser()
@@ -77,7 +78,7 @@ def _CheckTagsInFile(self, filename, should_be_wellformed, should_be_valid):
full_filename = os.path.join(os.path.dirname(__file__), "testdata",
filename)
fileObj = codecs.open(full_filename, "r", "utf-8" )
for line in fileObj.xreadlines():
for line in fileObj:
line_parts = line.split("#")
tag = line_parts[0].strip()
if tag:
@@ -14,12 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import transitfeed
import agency
import fareattribute
import route
import stop
import board_alight

from . import agency
from . import fareattribute
from . import route
from . import stop
from . import board_alight

def GetGtfsFactory(factory = None):
if not factory:
@@ -26,7 +26,7 @@ class Stop(transitfeed.Stop):
- Overriding ValidateStopLocationType(), adding location_type 2 (entrance).
"""

_FIELD_NAMES = transitfeed.Stop._FIELD_NAMES + ['vehicle_type']
_FIELD_NAMES = transitfeed.Stop._FIELD_NAMES + ['vehicle_type', 'platform_code']

LOCATION_TYPE_ENTRANCE = 2

@@ -19,6 +19,7 @@
For usage information run feedvalidator.py --help
"""
from __future__ import print_function

import bisect
import codecs
@@ -333,7 +334,7 @@ def FormatException(self, e, output):
transitfeed.EncodeUnicode(table_header))
output.append('<tr>%s</tr></table>\n' %
transitfeed.EncodeUnicode(table_data))
except AttributeError, e:
except AttributeError as e:
pass # Hope this was getting an attribute from e ;-)
output.append('<br></li>\n')

@@ -517,8 +518,8 @@ def RunValidationOutputToFilename(feed, options, output_filename):
output_file = open(output_filename, 'w')
exit_code = RunValidationOutputToFile(feed, options, output_file)
output_file.close()
except IOError, e:
print 'Error while writing %s: %s' % (output_filename, e)
except IOError as e:
print('Error while writing %s: %s' % (output_filename, e))
output_filename = None
exit_code = 2

@@ -583,8 +584,8 @@ def RunValidation(feed, options, problems):

gtfs_factory = extension_module.GetGtfsFactory()

print 'validating %s' % feed
print 'FeedValidator extension used: %s' % options.extension
print('validating %s' % feed)
print('FeedValidator extension used: %s' % options.extension)
loader = gtfs_factory.Loader(feed, problems=problems, extra_validation=False,
memory_db=options.memory_db,
check_duplicate_trips=\
@@ -601,10 +602,10 @@ def RunValidation(feed, options, problems):

accumulator = problems.GetAccumulator()
if accumulator.HasIssues():
print 'ERROR: %s found' % accumulator.FormatCount()
print('ERROR: %s found' % accumulator.FormatCount())
return schedule, 1
else:
print 'feed validated successfully'
print('feed validated successfully')
return schedule, 0


@@ -719,9 +720,9 @@ def ProfileRunValidationOutputFromOptions(feed, options):

# Only available on Unix, http://docs.python.org/lib/module-resource.html
import resource
print "Time: %d seconds" % (
print("Time: %d seconds" % (
resource.getrusage(resource.RUSAGE_SELF).ru_utime +
resource.getrusage(resource.RUSAGE_SELF).ru_stime)
resource.getrusage(resource.RUSAGE_SELF).ru_stime))

# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286222
# http://aspn.activestate.com/ASPN/Cookbook/ "The recipes are freely
@@ -755,7 +756,7 @@ def _VmB(VmKey):

# I ran this on over a hundred GTFS files, comparing VmSize to VmRSS
# (resident set size). The difference was always under 2% or 3MB.
print "Virtual Memory Size: %d bytes" % _VmB('VmSize:')
print("Virtual Memory Size: %d bytes" % _VmB('VmSize:'))

# Output report of where CPU time was spent.
p = pstats.Stats('validate-stats')
@@ -32,6 +32,7 @@
and draws marey graphs in svg/xml format on request.
"""
from __future__ import print_function

import itertools
import transitfeed
@@ -292,7 +293,7 @@ def DistanceInTravelTime(dep_secs, arr_secs):
return t_dists2

def _AddWarning(self, str):
print str
print(str)

def _DrawTrips(self,triplist,colpar=""):
"""Generates svg polylines for each transit trip.
@@ -27,6 +27,7 @@
For line geometries, information about shapes is extracted from a kml file.
"""
from __future__ import print_function

import re
import string
@@ -160,7 +161,7 @@ def main():
parser.Parse(args[0], feed)
feed.WriteGoogleTransitFeed(args[1])

print "Done."
print("Done.")


if __name__ == '__main__':
@@ -68,10 +68,11 @@
- Routes - Rail
- Shapes
"""
from __future__ import print_function

try:
import xml.etree.ElementTree as ET # python 2.5
except ImportError, e:
except ImportError as e:
import elementtree.ElementTree as ET # older pythons
import extensions.googletransit as googletransit
import optparse
@@ -790,16 +791,16 @@ def main():
try:
loader = transitfeed.Loader(input_path)
feed = loader.Load()
except transitfeed.ExceptionWithContext, e:
print >>sys.stderr, (
except transitfeed.ExceptionWithContext as e:
print((
"\n\nGTFS feed must load without any errors.\n"
"While loading %s the following error was found:\n%s\n%s\n" %
(input_path,
e.FormatContext(),
transitfeed.EncodeUnicode(e.FormatProblem())))
transitfeed.EncodeUnicode(e.FormatProblem()))), file=sys.stderr)
sys.exit(1)

print "Writing %s" % output_path
print("Writing %s" % output_path)
writer = KMLWriter()
writer.show_trips = options.show_trips
writer.altitude_per_sec = options.altitude_per_sec
@@ -22,6 +22,7 @@
# Usage:
# location_editor.py --key `cat key` --port 8765 --feed_filename feed.zip

from __future__ import print_function
import schedule_viewer
import transitfeed

@@ -39,7 +40,7 @@ def handle_json_GET_setstoplocation(self, params):
stop.stop_lon = float(lon)
msg = 'Location of ' + stop['stop_name'] + '(' + stop_id + ') set to ' + \
lat + 'x' + lon
print msg
print(msg)
return msg

def handle_json_GET_savedata(self, params):
@@ -49,7 +50,7 @@ def handle_json_GET_savedata(self, params):
else:
schedule.WriteGoogleTransitFeed(self.server.feed_path)
msg = 'Data saved to ' + self.server.feed_path
print msg
print(msg)
return msg

def AllowEditMode(self):

0 comments on commit 0c6f82d

Please sign in to comment.
You can’t perform that action at this time.