Only use the System column instead of loading the whole csv file

This commit is contained in:
CMDR-Kiel42 2019-06-15 22:44:58 +02:00
parent 85b9c79c7a
commit be4844742d

14
load.py
View File

@ -28,9 +28,9 @@ def plugin_start():
# Open the last saved route
with open(this.save_route_path, 'r') as csvfile:
route_reader = csv.reader(csvfile)
this.route = [row for row in route_reader]
this.route = [row[0] for row in route_reader]
this.next_stop = this.route[1][0]
this.next_stop = this.route[1]
except:
print("No previously saved route.")
@ -39,9 +39,7 @@ def plugin_stop():
if this.route.__len__() != 0:
# Save route for next time
with open(this.save_route_path, 'w') as csvfile:
route_writer = csv.writer(csvfile)
for row in this.route:
route_writer.writerow(row)
csvfile.write('\n'.join(this.route))
def update_gui():
this.waypoint_btn["text"] = this.next_wp_label + this.next_stop
@ -63,12 +61,12 @@ def new_route(self=None):
with open(filename, 'r') as csvfile:
route_reader = csv.reader(csvfile)
this.route = [row for row in route_reader]
this.route = [row[0] for row in route_reader]
if monitor.system == this.route[1][0]:
del this.route[1]
this.next_stop = this.route[1][0]
this.next_stop = this.route[1]
copy_waypoint()
update_gui()
@ -80,7 +78,7 @@ def update_route():
if os.path.isfile(this.save_route_path):
os.remove(this.save_route_path)
else:
this.next_stop = this.route[1][0]
this.next_stop = this.route[1]
update_gui()
copy_waypoint(this.parent)