Add extra shapes into our input set by parsing them out of a GTFS-formatted
  shapes.txt file.  Useful for manually adding lines to a shape file, since it's
  a pain to edit .shp files.

def AddExtraShapes(extra_shapes_txt, graph):
  """
  Add extra shapes into our input set by parsing them out of a GTFS-formatted
  shapes.txt file.  Useful for manually adding lines to a shape file, since it's
  a pain to edit .shp files.
  """

  print("Adding extra shapes from %s" % extra_shapes_txt)
  try:
    tmpdir = tempfile.mkdtemp()
    shutil.copy(extra_shapes_txt, os.path.join(tmpdir, 'shapes.txt'))
    loader = transitfeed.ShapeLoader(tmpdir)
    schedule = loader.Load()
    for shape in schedule.GetShapeList():
      print("Adding extra shape: %s" % shape.shape_id)
      graph.AddPoly(ShapeToPoly(shape))
  finally:
    if tmpdir:
      shutil.rmtree(tmpdir)