def get_file_array(self): path = os.path.join("generated/splits/", ("%s.splt" % self.id)) if not os.path.exists(path): return None f = open(path) resp = f.read() f.close() lines = resp.splitlines() return [(lines[i], time_format.num_to_string(int(lines[i+1])) if lines[i+1] else "") for i in range(1, int(lines[0])*2, 2)]
def race_page(rid): rq = Race.query.get(rid) if rq: if rq.finished: data = rq.get_file_results() for d in data: times = d["times"] d["times"] = [time_format.num_to_string(t) for t in times] users = [User.query.get(int(p["uid"])) for p in data] return render_template("race.html", title=rq.split.name, race=rq, rdata=data, users=users, split=rq.split.get_file_array()) return render_template("race.html", title=rq.split.name, race=rq) return render_template("errorpage.html", title="Race not found.", mainMess="A race with the id of %s was not found" % rid, sideMess="Please make sure the link is valid.")