2 # Copyright (C) 2013-2024 EDF
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
22 rep=os.path.dirname(os.path.abspath(__file__))
23 installDir=os.path.join(rep,'..')
24 sys.path.insert(0,installDir)
26 from qtsalome import *
27 from Base.dataBase import Base
29 def completeDatabase(fichier,table,enregistrement):
32 nomTable="ma"+str(table)
33 matable=getattr(maBase,nomTable)
34 model= QSqlTableModel()
35 model.setTable(matable.nom)
36 nbCols=model.columnCount() -1
37 if table == "TableGroupesRef" : nbCols==nbCols+1
38 if len(enregistrement) != nbCols :
39 print("mauvais nb de valeurs")
40 print("Attention, ne pas renter d'Id")
41 if table == "TableGroupesRef" : matable.insereLigne(enregistrement)
42 else : matable.insereLigneAutoId(enregistrement)
47 if __name__ == "__main__":
48 from argparse import ArgumentParser
50 p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database')
51 p.add_argument('table',help='nom de la table a completer')
52 p.add_argument('enregistrement', nargs="+")
54 if args.table is None :
55 print("table obligatoire")
57 good_tables = ("TableMaillages","TableMailleurs","TableGroupesRef","TableVersions")
58 if args.table not in good_tables:
59 print("la table doit etre : %s" % ' ou '.join(good_tables))
61 completeDatabase(args.database,args.table,args.enregistrement)