Skip to content
Permalink
Browse files

Switch to absolute imports for Python3 compatability

Part of google#412

Started by:
futurize -nw -f libfuturize.fixes.fix_absolute_import  .
And followed up by fixing a few local problems.
  • Loading branch information...
jarondl committed Jan 28, 2019
1 parent 14ee635 commit 03374f03b000e49db09c78c281e477de4881789a
@@ -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 *
@@ -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()
@@ -14,12 +14,13 @@
# 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
from . import agency
from . import fareattribute
from . import route
from . import stop

def GetGtfsFactory(factory = None):
if not factory:
@@ -56,33 +56,34 @@
TimeToSecondsSinceMidnight(): Convert HH:MM:SS into seconds since midnight.
FormatSecondsSinceMidnight(s): Formats number of seconds past midnight into a string
"""
from __future__ import absolute_import

# util needs to be imported before problems because otherwise the loading order
# of this module is Agency -> Problems -> Util -> Trip and trip tries to
# use problems.default_problem_reporter as a default argument (which fails
# because problems.py isn't fully loaded yet). Loading util first solves this as
# problems.py gets fully loaded right away.
# TODO: Solve this problem cleanly
from util import *
from agency import *
from fareattribute import *
from farerule import *
from frequency import *
from gtfsfactory import *
from gtfsfactoryuser import *
from gtfsobjectbase import *
from loader import *
from problems import *
from route import *
from schedule import *
from serviceperiod import *
from shape import *
from shapelib import *
from shapeloader import *
from shapepoint import *
from stop import *
from stoptime import *
from transfer import *
from trip import *
from .util import *
from .agency import *
from .fareattribute import *
from .farerule import *
from .frequency import *
from .gtfsfactory import *
from .gtfsfactoryuser import *
from .gtfsobjectbase import *
from .loader import *
from .problems import *
from .route import *
from .schedule import *
from .serviceperiod import *
from .shape import *
from .shapelib import *
from .shapeloader import *
from .shapepoint import *
from .stop import *
from .stoptime import *
from .transfer import *
from .trip import *

from transitfeed.version import __version__
@@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gtfsobjectbase import GtfsObjectBase
from problems import default_problem_reporter
import util
from __future__ import absolute_import
from .gtfsobjectbase import GtfsObjectBase
from .problems import default_problem_reporter
from . import util

class Agency(GtfsObjectBase):
"""Represents an agency in a schedule.
@@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gtfsobjectbase import GtfsObjectBase
from problems import default_problem_reporter
import util
from __future__ import absolute_import
from .gtfsobjectbase import GtfsObjectBase
from .problems import default_problem_reporter
from . import util

class FareAttribute(GtfsObjectBase):
"""Represents a fare type."""
@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from problems import default_problem_reporter
from gtfsobjectbase import GtfsObjectBase
from __future__ import absolute_import
from .problems import default_problem_reporter
from .gtfsobjectbase import GtfsObjectBase

class FareRule(GtfsObjectBase):
"""This class represents a rule that determines which itineraries a
@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gtfsobjectbase import GtfsObjectBase
import util
from __future__ import absolute_import
from .gtfsobjectbase import GtfsObjectBase
from . import util

class Frequency(GtfsObjectBase):
"""This class represents a period of a trip during which the vehicle travels
@@ -14,22 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from agency import Agency
from fareattribute import FareAttribute
from farerule import FareRule
from feedinfo import FeedInfo
from frequency import Frequency
from loader import Loader
import problems
from route import Route
from schedule import Schedule
from serviceperiod import ServicePeriod
from shape import Shape
from shapepoint import ShapePoint
from stop import Stop
from stoptime import StopTime
from transfer import Transfer
from trip import Trip
from __future__ import absolute_import
from .agency import Agency
from .fareattribute import FareAttribute
from .farerule import FareRule
from .feedinfo import FeedInfo
from .frequency import Frequency
from .loader import Loader
from . import problems
from .route import Route
from .schedule import Schedule
from .serviceperiod import ServicePeriod
from .shape import Shape
from .shapepoint import ShapePoint
from .stop import Stop
from .stoptime import StopTime
from .transfer import Transfer
from .trip import Trip

class GtfsFactory(object):
"""A factory for the default GTFS objects"""
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
class GtfsFactoryUser(object):
"""Base class for objects that must store a GtfsFactory in order to
be able to instantiate Gtfs classes.
@@ -38,7 +39,7 @@ def GetGtfsFactory(self):
# This is why the import is here and not at the top level.
# When this runs, gtfsfactory should have already been loaded
# by other modules, avoiding the circular imports.
import gtfsfactory
from . import gtfsfactory
self._gtfs_factory = gtfsfactory.GetGtfsFactory()
return self._gtfs_factory

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

from gtfsfactoryuser import GtfsFactoryUser
from __future__ import absolute_import
from .gtfsfactoryuser import GtfsFactoryUser

class GtfsObjectBase(GtfsFactoryUser):
"""Object with arbitrary attributes which may be added to a schedule.
@@ -14,16 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import codecs
import cStringIO as StringIO
import csv
import os
import re
import zipfile

import gtfsfactory as gtfsfactory_module
import problems
import util
from . import gtfsfactory as gtfsfactory_module
from . import problems
from . import util

class Loader:
def __init__(self,
@@ -15,10 +15,11 @@
# limitations under the License.

from __future__ import print_function
from __future__ import absolute_import
import logging
import time

import util
from . import util

# Problem types:
# Error: A data issue not allowed by the GTFS spec.
@@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from gtfsobjectbase import GtfsObjectBase
import problems as problems_module
import util
from __future__ import absolute_import
from .gtfsobjectbase import GtfsObjectBase
from . import problems as problems_module
from . import util

class Route(GtfsObjectBase):
"""Represents a single route."""
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import bisect
import cStringIO as StringIO
import datetime
@@ -39,10 +40,10 @@
import weakref
import zipfile

import gtfsfactory
import problems as problems_module
from . import gtfsfactory
from . import problems as problems_module
from transitfeed.util import defaultdict
import util
from . import util

class Schedule(object):
"""Represents a Schedule, a collection of stops, routes, trips and
@@ -14,12 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import datetime
import re
import time

import problems as problems_module
import util
from . import problems as problems_module
from . import util

class ServicePeriod(object):
"""Represents a service, which identifies a set of dates when one or more
@@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import bisect

from gtfsfactoryuser import GtfsFactoryUser
import problems as problems_module
import util
from .gtfsfactoryuser import GtfsFactoryUser
from . import problems as problems_module
from . import util

class Shape(GtfsFactoryUser):
"""This class represents a geographic shape that corresponds to the route
@@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from loader import Loader
from __future__ import absolute_import
from .loader import Loader

class ShapeLoader(Loader):
"""A subclass of Loader that only loads the shapes from a GTFS file."""
@@ -15,10 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import bisect
from gtfsobjectbase import GtfsObjectBase
import problems as problems_module
import util
from .gtfsobjectbase import GtfsObjectBase
from . import problems as problems_module
from . import util
import sys

class ShapePoint(GtfsObjectBase):
@@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import warnings

from gtfsobjectbase import GtfsObjectBase
import problems as problems_module
import util
from .gtfsobjectbase import GtfsObjectBase
from . import problems as problems_module
from . import util

class Stop(GtfsObjectBase):
"""Represents a single stop. A stop must have a latitude, longitude and name.

0 comments on commit 03374f0

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