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 = scheduler.Scheduler()
schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg")) schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg"))
if props.format == "web": if props.format == "web":
tool.Web.send_webui_data( tool.Web.send_webui_data(data=ifc_csv.dataframe.to_csv(index=False), data_key="csv_data", event="csv_data")
extra_data=ifc_csv.dataframe.to_csv(index=False), extra_data_key="csv_data", event="csv_data"
)
self.report({"INFO"}, f"Data is exported to {props.format.upper()}.") self.report({"INFO"}, f"Data is exported to {props.format.upper()}.")
return {"FINISHED"} return {"FINISHED"}
+4 -2
View File
@@ -1546,14 +1546,16 @@ class Sequence(blenderbim.core.tool.Sequence):
) -> None: ) -> None:
if bpy.context.scene.WebProperties.is_connected: if bpy.context.scene.WebProperties.is_connected:
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} 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 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.html"), "w") as f:
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t: 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") task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8")
f.write( 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")) 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") print("Websocket server terminated successfully")
@classmethod @classmethod
def send_webui_data( def send_webui_data(cls, data=None, data_key="data", event="data", namespace="/blender", use_web_data=True):
cls, extra_data=None, extra_data_key="data", event="data", namespace="/blender", use_web_data=True
):
global ws_thread global ws_thread
data = {} payload = {}
if use_web_data: if use_web_data:
if not WebData.is_loaded: if not WebData.is_loaded:
WebData.load() WebData.load()
data = WebData.data payload = WebData.data
if extra_data is not None: if data is not None:
data[extra_data_key] = extra_data payload[data_key] = data
if ws_thread is not None and bpy.context.scene.WebProperties.is_connected: 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 @classmethod
def check_operator_queue(cls): def check_operator_queue(cls):
@@ -210,7 +208,7 @@ class Web(blenderbim.core.tool.Web):
work_schedule = ifc_file.by_id(operator_data["workScheduleId"]) work_schedule = ifc_file.by_id(operator_data["workScheduleId"])
task_json = tool.Sequence.create_tasks_json(work_schedule) task_json = tool.Sequence.create_tasks_json(work_schedule)
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} 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 @classmethod
def open_web_browser(cls, port): def open_web_browser(cls, port):