Loading src/ips_fastran_gui/app/models/main_model.py +3 −29 Original line number Diff line number Diff line """Module for the main model.""" import json import os import sys import zipfile from enum import Enum from pathlib import Path from shutil import copytree from typing import Any, Dict, List from pydantic import BaseModel, Field Loading Loading @@ -122,34 +122,8 @@ class MainModel: return file def read_files(self, file_path: str) -> None: self.file_tree = {} for dirpath, _, filenames in os.walk(file_path): relative_path = os.path.relpath(dirpath, file_path) if relative_path == ".": relative_path = "" parts = [] else: parts = relative_path.split("/") current_level = self.file_tree for part in parts: if part not in current_level: current_level[part] = {} current_level = current_level[part] for file in filenames: try: path = os.path.join(dirpath, file) with open(path, "r") as file_obj: current_level[file] = { "content": file_obj.read(), "name": file, "path": path, "relative_path": os.path.join(relative_path, file), } except Exception: pass def read_files(self, file_path: str, local_directory: str) -> None: copytree(file_path, local_directory, dirs_exist_ok=True) def set_files(self, file_tree: Dict[str, Any]) -> None: self.file_tree = file_tree Loading src/ips_fastran_gui/app/models/tool_implementations/local.py +1 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import os import subprocess from datetime import datetime as dt from shutil import copy from typing import Any, Dict, List, Optional Loading Loading @@ -69,10 +68,7 @@ class LocalTool: self.model.execution.success = False def run(self, *args: Any, **kwargs: Any) -> None: self.working_directory = os.path.join( os.path.dirname(self.model.resource_params.executable), f"run-{dt.now().isoformat()}" ) os.makedirs(self.working_directory, exist_ok=True) self.working_directory = args[0] self.output_directory = os.path.join(self.working_directory, "output") self.process = subprocess.Popen( Loading src/ips_fastran_gui/app/view_models/main_view_model.py +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class MainViewModel: for update in updated: match update: case "input_file_path": self.model.read_files(self.view_state.input_file_path) self.model.read_files(self.view_state.input_file_path, self.local_directory) self.config_bind.update_in_view(self.model.config) def on_completion(self, _sender: Any) -> None: Loading Loading
src/ips_fastran_gui/app/models/main_model.py +3 −29 Original line number Diff line number Diff line """Module for the main model.""" import json import os import sys import zipfile from enum import Enum from pathlib import Path from shutil import copytree from typing import Any, Dict, List from pydantic import BaseModel, Field Loading Loading @@ -122,34 +122,8 @@ class MainModel: return file def read_files(self, file_path: str) -> None: self.file_tree = {} for dirpath, _, filenames in os.walk(file_path): relative_path = os.path.relpath(dirpath, file_path) if relative_path == ".": relative_path = "" parts = [] else: parts = relative_path.split("/") current_level = self.file_tree for part in parts: if part not in current_level: current_level[part] = {} current_level = current_level[part] for file in filenames: try: path = os.path.join(dirpath, file) with open(path, "r") as file_obj: current_level[file] = { "content": file_obj.read(), "name": file, "path": path, "relative_path": os.path.join(relative_path, file), } except Exception: pass def read_files(self, file_path: str, local_directory: str) -> None: copytree(file_path, local_directory, dirs_exist_ok=True) def set_files(self, file_tree: Dict[str, Any]) -> None: self.file_tree = file_tree Loading
src/ips_fastran_gui/app/models/tool_implementations/local.py +1 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import os import subprocess from datetime import datetime as dt from shutil import copy from typing import Any, Dict, List, Optional Loading Loading @@ -69,10 +68,7 @@ class LocalTool: self.model.execution.success = False def run(self, *args: Any, **kwargs: Any) -> None: self.working_directory = os.path.join( os.path.dirname(self.model.resource_params.executable), f"run-{dt.now().isoformat()}" ) os.makedirs(self.working_directory, exist_ok=True) self.working_directory = args[0] self.output_directory = os.path.join(self.working_directory, "output") self.process = subprocess.Popen( Loading
src/ips_fastran_gui/app/view_models/main_view_model.py +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class MainViewModel: for update in updated: match update: case "input_file_path": self.model.read_files(self.view_state.input_file_path) self.model.read_files(self.view_state.input_file_path, self.local_directory) self.config_bind.update_in_view(self.model.config) def on_completion(self, _sender: Any) -> None: Loading