From 54b5a503d6f01de5e115557706de35d7cba696a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Kalvoda?= <jirikalvoda@kam.mff.cuni.cz>
Date: Sun, 21 Jul 2024 10:17:50 +0200
Subject: [PATCH] FIXUPs

---
 prog/data_utils.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/prog/data_utils.py b/prog/data_utils.py
index d2e99b6..ded0997 100644
--- a/prog/data_utils.py
+++ b/prog/data_utils.py
@@ -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:
-- 
GitLab