Пример #1
0
class Confufish:
    def __init__(self, config_file):
        """Reads configuration file and creates router"""
        conf = self.read_config(config_file)
        # Create a world.
        world = World(dialect, username, password, server, port, database)
        # Create the actors.
        self.actors = Actors(url, key)
        # Create the router
        self.router = Router(world)

    def read_config(self, config_file):
        # Read the configuration file
        config = ConfigParser.SafeConfigParser()
        config.read(config_file)
        conf = {"world": {}}
        # Read world data from the config.
        conf["world"]["dialect"] = config.get("World", "dialect")
        username = config.get("World", "username")
        password = config.get("World", "password")
        server = config.get("World", "server")
        port = config.get("World", "port")
        database = config.get("World", "database")
        # Read actor data from the config.
        url = config.get("Actors", "url")
        key = config.get("Actors", "key")

    def itinerary(self):
        """Given a delivery id finds the shortest itinerary."""
        self.actors.update()
        self.router.itinerary(self.actors)
Пример #2
0
 def __init__(self, config_file):
     """Reads configuration file and creates router"""
     conf = self.read_config(config_file)
     # Create a world.
     world = World(dialect, username, password, server, port, database)
     # Create the actors.
     self.actors = Actors(url, key)
     # Create the router
     self.router = Router(world)