+ import daCore.version as dav
+ return "%s %s (%s)"%(dav.name,dav.version,dav.date)
+
+# ==============================================================================
+try:
+ import scipy
+ import scipy.version
+ import scipy.optimize
+ has_scipy = True
+except ImportError:
+ has_scipy = False
+
+try:
+ import matplotlib
+ has_matplotlib = True
+except ImportError:
+ has_matplotlib = False
+
+try:
+ import Gnuplot
+ has_gnuplot = True
+except ImportError:
+ has_gnuplot = False
+
+try:
+ import sphinx
+ has_sphinx = True
+except ImportError:
+ has_sphinx = False
+
+try:
+ import nlopt
+ has_nlopt = True
+except ImportError:
+ has_nlopt = False
+
+try:
+ import sdf
+ has_sdf = True
+except ImportError:
+ has_sdf = False
+
+has_salome = bool( "ROOT_SALOME" in os.environ )
+has_yacs = bool( "YACS_ROOT_DIR" in os.environ )
+has_adao = bool( "ADAO_ROOT_DIR" in os.environ )
+has_eficas = bool( "EFICAS_ROOT_DIR" in os.environ )
+
+# ==============================================================================
+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)]
+
+def isIterable( __sequence, __check = False, __header = "" ):
+ """
+ Vérification que l'argument est un itérable
+ """
+ if isinstance( __sequence, (list, tuple, map) ):
+ __isOk = True
+ elif type(__sequence).__name__ in ('generator','range'):
+ __isOk = True
+ elif "_iterator" in type(__sequence).__name__:
+ __isOk = True
+ else:
+ __isOk = False
+ if __check and not __isOk:
+ raise TypeError("Not iterable or unkown input type%s: %s"%(__header, type(__sequence),))
+ return __isOk
+
+def date2int( __date, __lang="FR" ):
+ """
+ Fonction de secours, conversion pure : dd/mm/yy hh:mm ---> int(yyyymmddhhmm)
+ """
+ __date = __date.strip()
+ if __date.count('/') == 2 and __date.count(':') == 0 and __date.count(' ') == 0:
+ d,m,y = __date.split("/")
+ __number = (10**4)*int(y)+(10**2)*int(m)+int(d)
+ elif __date.count('/') == 2 and __date.count(':') == 1 and __date.count(' ') > 0:
+ part1, part2 = __date.split()
+ d,m,y = part1.strip().split("/")
+ h,n = part2.strip().split(":")
+ __number = (10**8)*int(y)+(10**6)*int(m)+(10**4)*int(d)+(10**2)*int(h)+int(n)
+ else:
+ raise ValueError("Cannot convert \"%s\" as a D/M/Y H:M date"%d)
+ return __number
+
+def checkFileNameConformity( __filename, __warnInsteadOfPrint=True ):
+ if sys.platform.startswith("win") and len(__filename) > 256:
+ __conform = False
+ __msg = (" For some shared or older file systems on Windows, a file "+\
+ "name longer than 256 characters can lead to access problems."+\
+ "\n The name of the file in question is the following:"+\
+ "\n %s")%(__filename,)
+ if __warnInsteadOfPrint: logging.warning(__msg)
+ else: print(__msg)
+ else:
+ __conform = True
+ #
+ return __conform
+
+def checkFileNameImportability( __filename, __warnInsteadOfPrint=True ):
+ if str(__filename).count(".") > 1:
+ __conform = False
+ __msg = (" The file name contains %i point(s) before the extension "+\
+ "separator, which can potentially lead to problems when "+\
+ "importing this file into Python, as it can then be recognized "+\
+ "as a sub-module (generating a \"ModuleNotFoundError\"). If it "+\
+ "is intentional, make sure that there is no module with the "+\
+ "same name as the part before the first point, and that there is "+\
+ "no \"__init__.py\" file in the same directory."+\
+ "\n The name of the file in question is the following:"+\
+ "\n %s")%(int(str(__filename).count(".")-1), __filename)
+ if __warnInsteadOfPrint: logging.warning(__msg)
+ else: print(__msg)
+ else:
+ __conform = True
+ #
+ return __conform