class CatalogDescription(object):
def __init__(self, labelCode, fichierCata, formatFichierOut = "python", formatFichierIn='python',
- default = False, code = None,ss_code=None,):
+ default = False, code = None,ssCode=None, selectable = True, userName=None):
"""
This class can be used to describe an Eficas catalog.
:type code: string
:param code: Used to indicate the code associated to this catalog
- :type ss_code: string
- :param ss_code: scheme associated to this catalog (Map only)
+ :type ssCode: string
+ :param ssCode: scheme associated to this catalog (Map only)
+
+ :type userName: string
+ :param userName: name of the catalog as it will appear in the list
+
+ :type selectable: boolean
+ :param selectable: indicate if this catalog appears in the list.
+ Setting this parameter to False is useful to keep
+ old catalogs to edit existing files but to forbid
+ to use them to create new files.
+
+
"""
self.formatFichierIn = formatFichierIn
self.default = default
self.code = code
+ self.ssCode = ssCode
+ if userName is None:
+ self.userName = labelCode
+ else:
+ self.userName = userName
+ self.selectable = selectable
+
@staticmethod
def createFromTuple(cataTuple):
#print "Warning: Describing a catalog with a tuple is deprecated. " \
# "Please create a CatalogDescription instance directly."
+ if cataTuple[0] == 'TELEMAC':
+ desc = CatalogDescription(code = cataTuple[0],
+ ssCode = cataTuple[1],
+ labelCode = cataTuple[0]+cataTuple[1],
+ fichierCata = cataTuple[2],
+ formatFichierOut = cataTuple[3],
+ formatFichierIn = cataTuple[4])
+ return desc
if cataTuple[0] == 'MAP' :
desc = CatalogDescription(code = cataTuple[0],
labelCode = cataTuple[1],
"""
Class implementing the main user interface.
"""
- def __init__(self,code=None,salome=1,parent=None,multi=False,langue='fr',ssIhm=True,labelCode=None,genereXSD=False,fichierCata=None):
+ def __init__(self,code=None,salome=1,parent=None,multi=False,langue='fr',ssIhm=True,labelCode=None,genereXSD=False,fichierCata=None,ssCode=None,versionCode=None):
"""
Constructor
"""
self.ssIhm=True
self.code=code
self.genereXSD=genereXSD
+ self.versionCode=versionCode
+ self.ssCode=ssCode
self.dict_reels={}
self.fichierIn=None
if isinstance(catalogue, CatalogDescription): listeTousLesCatas.append(catalogue)
elif isinstance(catalogue, tuple) : listeTousLesCatas.append(CatalogDescription.createFromTuple(catalogue))
else: print(("Catalog description cannot be interpreted: ", catalogue))
+
+ if self.labelCode is None: listeCataPossibles = listeTousLesCatas
+ else :
+ for catalogue in listeTousLesCatas:
+ if catalogue.code == self.code and catalogue.ssCode == self.ssCode:
+ listeCataPossibles.append(catalogue)
+
+ if len(listeCataPossibles)==0:
+ try :
+ QMessageBox.critical(self.QWParent, tr("Import du catalogue"),
+ tr("Pas de catalogue defini pour le code ") + self.code)
+ except :
+ print("Pas de catalogue defini pour le code " + self.code)
+ if self.appliEficas.salome == 0 : sys.exit(1)
+ self.appliEficas.close()
+ return
- # This filter is only useful for codes that have subcodes (like MAP).
- # Otherwise, the "code" attribute of the catalog description can (should) be None.
- if self.ssCode is None: listeCataPossibles = listeTousLesCatas
+ if self.labelCode is not None:
+ # La version a ete fixee
+ for cata in listeCataPossibles:
+ if self.labelCode == cata.identifier:
+ self.fichierCata = cata.fichierCata
+ self.labelCode = cata.labelCode
+ self.appliEficas.formatFichierOut = cata.formatFichierOut
+ self.appliEficas.formatFichierIn = cata.formatFichierIn
else:
- for catalogue in listeTousLesCatas:
- if catalogue.code == self.code and catalogue.ssCode == self.ssCode: listeCataPossibles.append(catalogue)
+ cataChoiceList = []
+ for cata in listeCataPossibles:
+ if cata.selectable:
+ if cata.default : cataChoiceList.insert(0, cata)
+ else : cataChoiceList.append(cata)
# le catalogue est fixe dans la ligne de commande
if self.appliEficas.fichierCata != None :
generator.gener(objet_jdc,format)
L'ecriture du fichier au format ini par appel de la methode
- generator.writefile(nom_fichier)
+ generator.writeFile(nom_fichier)
Ses caracteristiques principales sont exposees dans des attributs
de classe :
# Le texte au format aplat est stocke dans l'attribut text
self.text=''
- def writefile(self,filename):
+ def writeFile(self,filename):
fp=open(filename,'w')
fp.write(self.text)
fp.close()