Salome HOME
Minor source update for OM compatibility
[modules/adao.git] / bin / AdaoYacsSchemaCreator.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2008-2024 EDF R&D
4 #
5 # This file is part of SALOME ADAO module
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # Author: AndrĂ© Ribes, andre.ribes@edf.fr, EDF R&D
24
25 import os, sys, logging
26 logging.basicConfig(level=logging.WARNING, format='%(levelname)-8s %(message)s')
27
28 logging.debug("-- Starting AdaoYacsSchemaCreator --")
29
30 # Check some basics variables
31 if "ADAO_ENGINE_ROOT_DIR" not in os.environ:
32     logging.fatal("You have to define ADAO_ENGINE_ROOT_DIR")
33     sys.exit(1)
34
35 try:
36     import adao
37     from daYacsSchemaCreator import run
38 except ImportError as e:
39     logging.fatal("\n  Import of YACS schema creator module failed, the error message is:\n" +
40                   "\n  %s\n"%(e,) +
41                   "\n  Add its installation directory in your PYTHONPATH.\n")
42     sys.exit(1)
43
44 # Parse arguments
45 from argparse import ArgumentParser
46 usage = "usage: %(prog)s [options] config_file yacs_schema_filename"
47 my_parser = ArgumentParser(usage=usage)
48 my_parser.add_argument('config_file')
49 my_parser.add_argument('yacs_schema_filename')
50 args = my_parser.parse_args()
51
52 if os.path.dirname(args.config_file) != '':
53     # Ajout dans le sys.path pour permettre l'import des fichiers inclus
54     sys.path.insert(0, os.path.dirname(args.config_file))
55
56 run.create_schema_from_file(args.config_file, args.yacs_schema_filename)