import sys
# Configuration de l'installation
INSTALLDIR = "@EFICAS_DIR@"
-sys.path[:0]=[INSTALLDIR]
+sys.path.insert(0,INSTALLDIR)
ADAO_INSTALL_DIR = "@PYTHON_SITE@/salome/daEficas"
-sys.path[:0]=[ADAO_INSTALL_DIR]
+sys.path.insert(0,ADAO_INSTALL_DIR)
# Configuration
import prefs
filepath = os.path.dirname(script)
filename = os.path.basename(script)
module_name = os.path.splitext(filename)[0]
-sys.path.insert(0,filepath)
+if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
+ sys.path.insert(0,filepath)
# Import script
__import__(module_name)
filepath = os.path.dirname(script)
filename = os.path.basename(script)
module_name = os.path.splitext(filename)[0]
-sys.path.insert(0,filepath)
+if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
+ sys.path.insert(0,filepath)
# Import script
__import__(module_name)
import Logging ; Logging.Logging() # A importer en premier
import Persistence
from BasicObjects import Operator
+from PlatformInfo import uniq
# ==============================================================================
class AssimilationStudy:
# qui est activée dans Persistence)
self.__parent = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
sys.path.insert(0, self.__parent)
- sys.path = list(set(sys.path)) # Conserve en unique exemplaire chaque chemin
+ sys.path = uniq( sys.path ) # Conserve en unique exemplaire chaque chemin
# ---------------------------------------------------------
def setBackground(self,
if not os.path.isfile(os.path.join(asPath,"daAlgorithms","__init__.py")):
raise ValueError("The given \""+asPath+"/daAlgorithms\" path must contain a file named \"__init__.py\"")
sys.path.insert(0, os.path.abspath(asPath))
- sys.path = list(set(sys.path)) # Conserve en unique exemplaire chaque chemin
+ sys.path = uniq( sys.path ) # Conserve en unique exemplaire chaque chemin
return 1
def get_diagnostics_main_path(self):
if not os.path.isfile(os.path.join(asPath,"daDiagnostics","__init__.py")):
raise ValueError("The given \""+asPath+"/daDiagnostics\" path must contain a file named \"__init__.py\"")
sys.path.insert(0, os.path.abspath(asPath))
- sys.path = list(set(sys.path)) # Conserve en unique exemplaire chaque chemin
+ sys.path = uniq( sys.path ) # Conserve en unique exemplaire chaque chemin
return 1
# -----------------------------------------------------------
import version
return "%s %s (%s)"%(version.name,version.version,version.date)
+# ==============================================================================
+def uniq(sequence):
+ """
+ Fonction pour rendre unique chaque élément d'une liste, en préservant l'ordre
+ """
+ __seen = set()
+ return [x for x in sequence if x not in __seen and not __seen.add(x)]
+
# ==============================================================================
class PathManagement:
"""
sys.path.insert(0, v )
#
# Conserve en unique exemplaire chaque chemin
- sys.path = list(set(sys.path))
+ sys.path = uniq( sys.path )
del parent
-
+
def getpaths(self):
"""
Renvoie le dictionnaire des chemins ajoutés
# Configuration de Eficas
# INSTALLDIR, REPINI est obligatoire
INSTALLDIR = "@EFICAS_DIR@"
-sys.path[:0]=[INSTALLDIR]
+sys.path.insert(0,INSTALLDIR)
# positionnee a repin au debut mise a jour dans configuration
repIni=os.path.dirname(os.path.abspath(__file__))
# Permet à EFICAS de faire ses import correctement
my_path = os.path.dirname(os.path.abspath(__file__))
ADAO_INSTALL_DIR = my_path + "/../daEficas"
- sys.path[:0]=[ADAO_INSTALL_DIR]
+ sys.path.insert(0,ADAO_INSTALL_DIR)
self.__parent = parent
node_script += "filepath = \"" + base_repertory + "\"\n"
else:
node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
- node_script += "sys.path.insert(0,os.path.dirname(filepath))\n"
+ node_script += "if sys.path.count(os.path.dirname(filepath))==0 or (sys.path.count(os.path.dirname(filepath))>0 and sys.path.index(os.path.dirname(filepath),0,1)>0):\n"
+ node_script += " sys.path.insert(0,os.path.dirname(filepath))\n"
node_script += script_str.read()
opt_script_node.setScript(node_script)
opt_script_node.edAddInputPort("computation", t_param_input)
node_script += "filepath = \"" + base_repertory + "\"\n"
else:
node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
- node_script += "sys.path.insert(0,os.path.dirname(filepath))\n"
+ node_script += "if sys.path.count(os.path.dirname(filepath))==0 or (sys.path.count(os.path.dirname(filepath))>0 and sys.path.index(os.path.dirname(filepath),0,1)>0):\n"
+ node_script += " sys.path.insert(0,os.path.dirname(filepath))\n"
node_script += default_script
node_script += analysis_file.read()
analysis_node.setScript(node_script)