def load_configuration(name):

        path = ConfigurationParser.PATH + name

        scheme = Scheme()
        conf_file = open(path, "r")
        conf_file.readline()
        stations_line = conf_file.readline().rstrip()
        names, times_sets = ConfigurationParser.parse_stations_string(stations_line)
        for name, time_set in zip(names, times_sets):
            scheme.add_station(name, time_set)

        conf_file.readline()
        ways_line = conf_file.readline().rstrip()
        times_to_pass, st1_names, st2_names, direct_properties = ConfigurationParser.parse_ways_string(ways_line)
        for time, st1, st2, property in zip(times_to_pass, st1_names, st2_names, direct_properties):
            scheme.add_way(time, st1, st2, property)

        conf_file.readline()
        trains_line = conf_file.readline().rstrip()
        names, routes = ConfigurationParser.parse_trains_string(trains_line)
        for name, route in zip(names, routes):
            scheme.add_train(name, route)

        return scheme
Esempio n. 2
0
def scheme1():
    stations = {Station("1"),
                Station("2"),
                Station("3"),
                Station("4"),
                Station("5"),
                }

    scheme = Scheme(stations)
    scheme.add_way(10, "1", "3")
    scheme.add_way(10, "2", "3")
    scheme.add_way(10, "4", "3")
    scheme.add_way(10, "5", "3")

    # scheme.add_train_by_route_names("pobeda", ["1", "3", "5"])
    # scheme.add_train_by_route_names("lenin", ["2", "3", "4"])

    # st1 = scheme.find_station_by_name("1")
    # st2 = scheme.find_station_by_name("2")
    # st3 = scheme.find_station_by_name("3")
    # st4 = scheme.find_station_by_name("4")
    # st5 = scheme.find_station_by_name("5")
    #
    # w13 = scheme.find_way_by_end_names("1", "3")
    # w23 = scheme.find_way_by_end_names("5", "3")
    # w43 = scheme.find_way_by_end_names("4", "3")
    # w53 = scheme.find_way_by_end_names("5", "3")

    # t1 = scheme.find_train_by_name("pobeda")
    # t2 = scheme.find_train_by_name("lenin")

    return scheme