# 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
        has_data = True
        writer.writerow(row)
    wrote_calendar_dates = False
    if has_data:
      wrote_calendar_dates = True
      self._WriteArchiveString(archive, 'calendar_dates.txt',
                               calendar_dates_string)

    calendar_string = StringIO()
    writer = util.CsvUnicodeWriter(calendar_string)
    writer.writerow(self._gtfs_factory.ServicePeriod._FIELD_NAMES)
    has_data = False
    for s in self.service_periods.values():
      row = s.GetCalendarFieldValuesTuple()
      if row:
        has_data = True
        writer.writerow(row)
    if has_data or not wrote_calendar_dates:
      self._WriteArchiveString(archive, 'calendar.txt', calendar_string)

    if 'stops' in self._table_columns:
      stop_string = StringIO()
      writer = util.CsvUnicodeWriter(stop_string)
      columns = self.GetTableColumns('stops')
      writer.writerow(columns)
      for s in self.stops.values():
        writer.writerow([util.EncodeUnicode(s[c]) for c in columns])
      self._WriteArchiveString(archive, 'stops.txt', stop_string)

    if 'routes' in self._table_columns:

# 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

        has_data = True
        writer.writerow(row)
    wrote_calendar_dates = False
    if has_data:
      wrote_calendar_dates = True
      self._WriteArchiveString(archive, 'calendar_dates.txt',
                               calendar_dates_string)

    calendar_string = StringIO()
    writer = util.CsvUnicodeWriter(calendar_string)
    writer.writerow(self._gtfs_factory.ServicePeriod._FIELD_NAMES)
    has_data = False
    for s in self.service_periods.values():
      row = s.GetCalendarFieldValuesTuple()
      if row:
        has_data = True
        writer.writerow(row)
    if has_data or not wrote_calendar_dates:
      self._WriteArchiveString(archive, 'calendar.txt', calendar_string)

    if 'stops' in self._table_columns:
      stop_string = StringIO()
      writer = util.CsvUnicodeWriter(stop_string)
      columns = self.GetTableColumns('stops')
      writer.writerow(columns)
      for s in self.stops.values():
        writer.writerow([util.EncodeUnicode(s[c]) for c in columns])
      self._WriteArchiveString(archive, 'stops.txt', stop_string)

    if 'routes' in self._table_columns:

      route_string = StringIO()