rename variables to have more meaningful names

This commit is contained in:
Ziad-I
2024-07-16 14:42:23 +03:00
committed by Dion Moult
parent 4e79384c8e
commit 216b3a4e37
3 changed files with 13 additions and 15 deletions
@@ -254,9 +254,7 @@ class ExportIfcCsv(bpy.types.Operator):
schedule_creator = scheduler.Scheduler()
schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg"))
if props.format == "web":
tool.Web.send_webui_data(
extra_data=ifc_csv.dataframe.to_csv(index=False), extra_data_key="csv_data", event="csv_data"
)
tool.Web.send_webui_data(data=ifc_csv.dataframe.to_csv(index=False), data_key="csv_data", event="csv_data")
self.report({"INFO"}, f"Data is exported to {props.format.upper()}.")
return {"FINISHED"}
+5 -3
View File
@@ -1546,14 +1546,16 @@ class Sequence(blenderbim.core.tool.Sequence):
) -> None:
if bpy.context.scene.WebProperties.is_connected:
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data")
tool.Web.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data")
return
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f:
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t:
task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8")
f.write(
pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info(recursive=True))})
pystache.render(
t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info(recursive=True))}
)
)
webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"))
+7 -9
View File
@@ -136,22 +136,20 @@ class Web(blenderbim.core.tool.Web):
print("Websocket server terminated successfully")
@classmethod
def send_webui_data(
cls, extra_data=None, extra_data_key="data", event="data", namespace="/blender", use_web_data=True
):
def send_webui_data(cls, data=None, data_key="data", event="data", namespace="/blender", use_web_data=True):
global ws_thread
data = {}
payload = {}
if use_web_data:
if not WebData.is_loaded:
WebData.load()
data = WebData.data
payload = WebData.data
if extra_data is not None:
data[extra_data_key] = extra_data
if data is not None:
payload[data_key] = data
if ws_thread is not None and bpy.context.scene.WebProperties.is_connected:
ws_thread.run_coro(cls.sio_send(data, event, namespace))
ws_thread.run_coro(cls.sio_send(payload, event, namespace))
@classmethod
def check_operator_queue(cls):
@@ -210,7 +208,7 @@ class Web(blenderbim.core.tool.Web):
work_schedule = ifc_file.by_id(operator_data["workScheduleId"])
task_json = tool.Sequence.create_tasks_json(work_schedule)
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
cls.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data")
cls.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data")
@classmethod
def open_web_browser(cls, port):