# Path: transitfeed/util.py
# class defaultdict(dict):
#   def __init__(self, default_factory=None, *a, **kw):
#     if (default_factory is not None and
#       not hasattr(default_factory, '__call__')):
#       raise TypeError('first argument must be callable')
#     dict.__init__(self, *a, **kw)
#     self.default_factory = default_factory
#   def __getitem__(self, key):
#     try:
#       return dict.__getitem__(self, key)
#     except KeyError:
#       return self.__missing__(key)
#   def __missing__(self, key):
#     if self.default_factory is None:
#       raise KeyError(key)
#     self[key] = value = self.default_factory()
#     return value
#   def __reduce__(self):
#     if self.default_factory is None:
#       args = tuple()
#     else:
#       args = self.default_factory,
#     return type(self), args, None, None, self.items()
#   def copy(self):
#     return self.__copy__()
#   def __copy__(self):
#     return type(self)(self.default_factory, self)
#   def __deepcopy__(self, memo):
#     import copy
#     return type(self)(self.default_factory,
#                       copy.deepcopy(self.items()))
#   def __repr__(self):
#     return 'defaultdict(%s, %s)' % (self.default_factory,
#                                     dict.__repr__(self))
# 
# Path: transitfeed/compat.py



import bisect
import datetime
import itertools
import os
  import sqlite3 as sqlite
import tempfile
import time
import warnings
import weakref
import zipfile
    from pysqlite2 import dbapi2 as sqlite
    from com.ziclix.python.sql import zxJDBC as sqlite
from . import gtfsfactoryuser
from . import problems as problems_module
from .util import defaultdict
from . import util
from .compat import StringIO
      shape_string = StringIO()
      writer = util.CsvUnicodeWriter(shape_string)
      writer.writerow(self._gtfs_factory.Shape._FIELD_NAMES)
      writer.writerows(shape_rows)
      self._WriteArchiveString(archive, 'shapes.txt', shape_string)

    if 'transfers' in self._table_columns:
      transfer_string = StringIO()
      writer = util.CsvUnicodeWriter(transfer_string)
      columns = self.GetTableColumns('transfers')
      writer.writerow(columns)
      for t in self.GetTransferIter():
        writer.writerow([util.EncodeUnicode(t[c]) for c in columns])
      self._WriteArchiveString(archive, 'transfers.txt', transfer_string)

    archive.close()

  def GenerateDateTripsDeparturesList(self, date_start, date_end):
    """Return a list of (date object, number of trips, number of departures).

    The list is generated for dates in the range [date_start, date_end).

    Args:
      date_start: The first date in the list, a date object
      date_end: The first date after the list, a date object

    Returns:
      a list of (date object, number of trips, number of departures) tuples
    """


# Path: transitfeed/util.py
# class defaultdict(dict):
#   def __init__(self, default_factory=None, *a, **kw):
#     if (default_factory is not None and
#       not hasattr(default_factory, '__call__')):
#       raise TypeError('first argument must be callable')
#     dict.__init__(self, *a, **kw)
#     self.default_factory = default_factory
#   def __getitem__(self, key):
#     try:
#       return dict.__getitem__(self, key)
#     except KeyError:
#       return self.__missing__(key)
#   def __missing__(self, key):
#     if self.default_factory is None:
#       raise KeyError(key)
#     self[key] = value = self.default_factory()
#     return value
#   def __reduce__(self):
#     if self.default_factory is None:
#       args = tuple()
#     else:
#       args = self.default_factory,
#     return type(self), args, None, None, self.items()
#   def copy(self):
#     return self.__copy__()
#   def __copy__(self):
#     return type(self)(self.default_factory, self)
#   def __deepcopy__(self, memo):
#     import copy
#     return type(self)(self.default_factory,
#                       copy.deepcopy(self.items()))
#   def __repr__(self):
#     return 'defaultdict(%s, %s)' % (self.default_factory,
#                                     dict.__repr__(self))
# 
# Path: transitfeed/compat.py



# Path: transitfeed/schedule.py
import bisect
import datetime
import itertools
import os
  import sqlite3 as sqlite
import tempfile
import time
import warnings
import weakref
import zipfile
    from pysqlite2 import dbapi2 as sqlite
    from com.ziclix.python.sql import zxJDBC as sqlite
from . import gtfsfactoryuser
from . import problems as problems_module
from .util import defaultdict
from . import util
from .compat import StringIO

      shape_string = StringIO()
      writer = util.CsvUnicodeWriter(shape_string)
      writer.writerow(self._gtfs_factory.Shape._FIELD_NAMES)
      writer.writerows(shape_rows)
      self._WriteArchiveString(archive, 'shapes.txt', shape_string)

    if 'transfers' in self._table_columns:
      transfer_string = StringIO()
      writer = util.CsvUnicodeWriter(transfer_string)
      columns = self.GetTableColumns('transfers')
      writer.writerow(columns)
      for t in self.GetTransferIter():
        writer.writerow([util.EncodeUnicode(t[c]) for c in columns])
      self._WriteArchiveString(archive, 'transfers.txt', transfer_string)

    archive.close()

  def GenerateDateTripsDeparturesList(self, date_start, date_end):
    """Return a list of (date object, number of trips, number of departures).

    The list is generated for dates in the range [date_start, date_end).

    Args:
      date_start: The first date in the list, a date object
      date_end: The first date after the list, a date object

    Returns:
      a list of (date object, number of trips, number of departures) tuples
    """


    service_id_to_trips = defaultdict(lambda: 0)