def load(self): station = None with open("data.json") as f: d = json.load(f) fuelList = list() for f in d["fuel"]: fuelList.append(Fuel(f["name"], f["tank"])) station = Station(d["name"]) station.__fuelList__ = fuelList return station
def load(self): """ Loads the station from Json file >>> st = Station("station") >>> st.add_fuel_type(Fuel("95",20)) >>> Serialization().save(st) >>> ser = Serialization().load() >>> ser.__fuelList__.__getitem__(0).__name__ '95' >>> ser.__fuelList__.__getitem__(0).__tank__ 20 >>> ser.__name__ 'station' """ with open("data.json") as f: d = json.load(f) fuel_list = list() for f in d["fuel"]: fuel_list.append(Fuel(f["name"], f["tank"])) station = Station(d["name"]) station.__fuelList__ = fuel_list return station