Ce module sert pour charger les paramètres de configuration d'EFICAS
"""
# Modules Python
-import os,sys,string,types
+import os, sys, string, types, re
import traceback
# Modules Eficas
for k in d['style'].__dict__.keys() :
setattr(self,k,d['style'].__dict__[k])
+ if hasattr(self,"catalogues") :
+ for ligne in self.catalogues :
+ version=ligne[1]
+ codeSansPoint=re.sub("\.","",version)
+ chaine="rep_mat_"+codeSansPoint
+ if hasattr(self,chaine):
+ rep_mat=getattr(self,chaine)
+ self.dRepMat[version]=str(rep_mat)
+
#--------------------------------------
def lecture_fichier_ini_utilisateur(self):
#--------------------------------------
CONFIGbase.__init__ (self,appli)
self.pref=""
+ #--------------------------------------
+ def save_params(self):
+ #--------------------------------------
+ # sauvegarde
+ # les nouveaux paramètres dans le fichier de configuration utilisateur
+ #
+ l_param=('exec_acrobat', 'rep_ini','catalogues','rep_travail','rep_mat','path_doc')
+ texte=""
+ for clef in l_param :
+ if hasattr(self,clef):
+ valeur=getattr(self,clef)
+ texte= texte + clef+" = " + repr(valeur) +"\n"
+
+
+ # recuperation des repertoires materiaux
+ try :
+ for item in self.catalogues :
+ try :
+ (code,version,cata,format,defaut)=item
+ except :
+ (code,version,cata,format)=item
+ codeSansPoint=re.sub("\.","",version)
+ chaine="rep_mat_"+codeSansPoint
+ if hasattr(self,chaine):
+ valeur=getattr(self,chaine)
+ texte= texte + chaine+" = '" + str(valeur) +"'\n"
+ except :
+ pass
+
+ f=open(self.fic_ini_utilisateur,'w+')
+ f.write(texte)
+ f.close()
+
class CONFIGStyle(CONFIGbase):
def __init__(self,appli,rep_ini):
from OptionsEditeur import desOptions
from qt import *
-import re
+import os, re
class Options(desOptions):
def __init__(self,parent = None,name = None,modal = 0,fl = 0,configuration=None):
self.dRepMat={}
self.dRepCat={}
self.initAll()
+ self.ajout=0
def initAll(self):
+ self.CBVersions.clear()
for item in self.configuration.catalogues :
try :
(code,version,cata,format,defaut)=item
self.dRepMat[version]=""
self.LERepMat.setText(self.dRepMat[version])
self.LERepCata.setText(self.dRepCat[version])
+ if hasattr(self.configuration,"path_doc"):
+ self.LERepDoc.setText(self.configuration.path_doc)
def VersionChoisie(self):
self.LERepCata.setText(self.dRepCat[version])
def BokClicked(self):
+ if self.ajout :
+ self.ajout=0
+ return
version=str(self.CBVersions.currentText())
+ if self.LERepCata.text() == "" :
+ QMessageBox.critical( self, "Champ non rempli","Le champs Catalogue doit etre rempli" )
+ return
+
self.dRepMat[version]=self.LERepMat.text()
- self.dRepCat[version]=self.LERepCata.text()
+ if str(self.dRepMat[version] != "") != "" :
+ codeSansPoint=re.sub("\.","",version)
+ chaine="rep_mat_"+codeSansPoint
+ setattr(self.configuration,chaine,self.dRepMat[version])
+
+ self.dRepCat[version]=str(self.LERepCata.text())
+ if version in self.dVersion.keys():
+ item=list(self.dVersion[version])
+ item[2]=self.dRepCat[version]
+ self.dVersion[version]=tuple(item)
+ else :
+ self.dVersion[version]=('ASTER',version,self.dRepCat[version],'python')
+
+ lItem=[]
+ for version in self.dVersion.keys() :
+ lItem.append(self.dVersion[version])
+ self.configuration.catalogues=lItem
+ self.configuration.save_params()
+
+ def AjoutVersion(self):
+ self.ajout=1
+ version=self.LEVersionAjout.text()
+ if str(version) == "" : return
+ self.CBVersions.insertItem(version,0)
+ self.LERepMat.setText("")
+ self.LERepCata.setText("")
+ self.LEVersionAjout.setText("")
+ def SupVersion(self):
+ self.ajout=1
+ version=str(self.LEVersionSup.text())
+ if version == "" : return
+ i =0
+ while i < self.CBVersions.count() :
+ if self.CBVersions.text(i) == version :
+ self.CBVersions.removeItem(i)
+ break
+ i=i+1
+ del self.dVersion[version]
+ del self.dRepMat[version]
+ del self.dRepCat[version]
codeSansPoint=re.sub("\.","",version)
chaine="rep_mat_"+codeSansPoint
- setattr(self.configuration,chaine,self.dRepMat[version])
+ if hasattr(self.configuration,chaine):
+ delattr(self.configuration,chaine)
+ self.LEVersionSup.setText("")
+
+ lItem=[]
+ for version in self.dVersion.keys() :
+ lItem.append(self.dVersion[version])
+ self.LERepMat.setText("")
+ self.LERepCata.setText("")
+ self.configuration.catalogues=lItem
+ self.configuration.save_params()
+ self.CBVersions.setCurrentItem(0)
+ self.VersionChoisie()
+
+
+ def BdefautChecked(self):
+ res = QMessageBox.warning(
+ None,
+ self.trUtf8("Restauration des parametres par defaut "),
+ self.trUtf8("Votre fichier editeur sera ecrase."),
+ self.trUtf8("&Ok"),
+ self.trUtf8("&Abandonner"))
+ self.Bdefaut.setState(QButton.Off)
+ if res == 1 : return
+
+ appli=self.configuration.appli
+ rep_ini=self.configuration.rep_ini
+ fic_ini_util=self.configuration.fic_ini_utilisateur
+ old_fic_ini_util=fic_ini_util+"_old"
+ commande="mv "+fic_ini_util+" "+old_fic_ini_util
+ os.system(commande)
+ from configuration import CONFIG
+ self.configuration=CONFIG(appli,rep_ini)
+ self.configuration.save_params()
+ self.dVersion={}
+ self.dRepMat={}
+ self.dRepCat={}
+ self.initAll()
+
+ def ChangePathDoc(self):
+ self.configuration.path_doc=str(self.LERepDoc.currentText())
self.configuration.save_params()