From 197cb9b2901659c396d91f0fc6dbb0a65b285ec9 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 7 Sep 2023 14:03:11 +0200 Subject: [PATCH] Gmsh example hardened, against calling from outside of parent folder, against samples folder exists but has not needed files. --- examples/show_gmsh.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/show_gmsh.py b/examples/show_gmsh.py index 0a30d6aa8..66ea1d2f1 100644 --- a/examples/show_gmsh.py +++ b/examples/show_gmsh.py @@ -13,10 +13,9 @@ mesh_file_tri = pathlib.Path("faces/tri/2DChannelTria.msh") mesh_file_quad = pathlib.Path("faces/quad/2DChannelQuad.msh") - base_samples_path = pathlib.Path("samples") - if not base_samples_path.exists(): - load_sample_file.load_sample_file(str(mesh_file_tri)) - load_sample_file.load_sample_file(str(mesh_file_quad)) + base_samples_path = pathlib.Path(__file__).parent / "samples" + load_sample_file.load_sample_file(str(mesh_file_tri)) + load_sample_file.load_sample_file(str(mesh_file_quad)) # load the .msh file directly with the correct io module (meshio) loaded_mesh_tri = io.meshio.load(base_samples_path / mesh_file_tri)