Skip to content
Snippets Groups Projects
Commit 54b5a503 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

FIXUPs

parent acecf412
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import math
import pprint
import time
import datetime
import pathlib
import gtfs
from utils import *
......@@ -229,20 +230,19 @@ class TripPoint:
self.openapi_next_stop = json['properties']['last_position']['next_stop']
self.openapi_delay = json['properties']['last_position']['delay']
def write_data(path, dt):
def write_data(dt, data):
import random
def only_printable_acii(s):
return all(ord(x) >= ord(' ') for x in s) and s.isascii()
tmp_file = dt.strftime(f"tmp/realtime-%Y-%m-%d--%H-%M-%S-{randint(random.randint(0,100000))}")
tmp_file = dt.strftime(f"tmp/realtime-%Y-%m-%d--%H-%M-%S-{random.randint(0,100000)}")
if type(data) == dict:
os.mkdir(tmp_file)
pathlib.Path(path)
for fname, d in data:
for fname, d in data.items():
assert '/' not in fname and only_printable_acii(fname)
with open(tmp_file+'/'+fname, "wb") as f:
with open(tmp_file+'/'+fname, "xb") as f:
f.write(d)
else:
with open(tmp_file, "xb") as f:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment