1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2019 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 class DefaultSchemaBuilder:
26 def __init__(self, prescript=None):
28 This object builds the YACS schema for the parametric computation.
29 prescript: contains python code that is executed before any evaluation.
31 self.prescript = prescript
33 def buildSchema(self, local_work_dir):
35 Create the YACS schema and copy it to local_work_dir.
36 local_work_dir : path where the schema will be created.
38 path to the created file,
39 list of additional files needed for running.
42 filename = inspect.getframeinfo(inspect.currentframe()).filename
43 install_directory = pathlib.Path(filename).resolve().parent
44 yacs_schema_path = os.path.join(install_directory, "schemas",
45 "idefix_pyschema.xml")
46 plugin_path = os.path.join(install_directory, "schemas", "plugin.py")
47 yacs_schema_path = shutil.copy(yacs_schema_path, local_work_dir)
48 plugin_path = shutil.copy(plugin_path, local_work_dir)
51 prescript_path = os.path.join(local_work_dir, "idefix_prescript.py")
52 with open(prescript_path, "w") as f:
53 f.write(self.prescript)
54 files.append(prescript_path)
55 return yacs_schema_path, files