else: key = "" + hours + minutes return int(key) if __name__ == "__main__": transport_dir = directories["IPHONE_DIR"] """ BALTIYSKIY BANK MIRA 17""" balt_bank_bus_list = ["bus_19", "bus_6", "bus_22"] balt_bank_position = [3, 8, 9] balt_bank_bus_dict = {} for bus_id in balt_bank_bus_list: balt_bank_bus_dict[bus_id] = load_json_file(transport_dir + bus_id + ".json") station_schedule = [] for i in range(len(balt_bank_bus_list)): bus_id = balt_bank_bus_list[i] sch = balt_bank_bus_dict[bus_id]["schedule_workdays"][balt_bank_position[i]] bus_id_list = [bus_id] * len(sch) sch = zip(bus_id_list, sch) station_schedule += sch station_schedule = [x for x in station_schedule if x[1] != "-"] station_schedule = sorted(station_schedule, key=time_key) station_schedule_buses = [x[0] for x in station_schedule] station_schedule_times = [x[1] for x in station_schedule] station_schedule_workdays_buses = station_schedule_buses station_schedule_workdays_times = station_schedule_times
for what in replace: if what["what"] == station: # print "\t", station, "=>", what['replace'] transport["stations_workdays"][i]["name"] = what["replace"] if "stations_weekend" in transport: for i in range(len(transport["stations_weekend"])): station = transport["stations_weekend"][i]["name"] for what in replace: if what["what"] == station: # print "\t", station, "=>", what['replace'] transport["stations_weekend"][i]["name"] = what["replace"] if __name__ == "__main__": onlyfiles = [f for f in listdir(TRANSPORT_DIR) if isfile(join(TRANSPORT_DIR, f))] replace = parser_utils.load_json_file(JSON_REPLACE) if "replace" in replace: replace = replace["replace"] for filename in onlyfiles: filename = TRANSPORT_DIR + filename print filename transport = parser_utils.load_json_file(filename) # print transport['name'] # if transport['id'] == "bus_27a": # if 'stations_workdays' in transport: # for station in transport['stations_workdays']: # print station['name'] + "|" # if 'stations_weekend' in transport: # for station in transport['stations_weekend']: