Salome HOME
Light cleaning of python code after pychecking
[modules/adao.git] / src / daComposant / daCore / PlatformInfo.py
index 6e50e12d711a12301269a5bd8df82dae7a1c9180..91dfb5f249d62d11556b47ae684a6dc8320b1913 100644 (file)
@@ -1,23 +1,25 @@
 #-*-coding:iso-8859-1-*-
 #
-#  Copyright (C) 2008-2009  EDF R&D
+# Copyright (C) 2008-2012 EDF R&D
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
+
 __doc__ = """
     Informations sur le code et la plateforme, et mise à jour des chemins
     
@@ -34,7 +36,7 @@ __doc__ = """
     simplement cette classe, sans meme récupérer d'objet :
         PathManagement()
 """
-__author__ = "Jean-Philippe ARGAUD - Mars 2008"
+__author__ = "Jean-Philippe ARGAUD"
 
 import os
 
@@ -81,13 +83,21 @@ class PlatformInfo:
         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:
     """
     Mise à jour du path système pour les répertoires d'outils
     """
     def __init__(self):
-        import os, sys
+        import sys
         parent = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
         self.__paths = {}
         self.__paths["daExternals"] = os.path.join(parent,"daExternals")
@@ -98,9 +108,9 @@ 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
@@ -120,12 +130,11 @@ class SystemUsage:
     _proc_status = '/proc/%d/status' % os.getpid()
     _memo_status = '/proc/meminfo'
     _scale = {
-        'o': 1.0,
-        'ko': 1024.0, 'mo': 1024.0*1024.0,
-        'Ko': 1024.0, 'Mo': 1024.0*1024.0,
-        'B':     1.0,
-        'kB': 1024.0, 'mB': 1024.0*1024.0,
-        'KB': 1024.0, 'MB': 1024.0*1024.0,
+                      'K' : 1024.0, 'M' : 1024.0*1024.0,
+        'o':     1.0, 'ko': 1024.0, 'mo': 1024.0*1024.0,
+                      'Ko': 1024.0, 'Mo': 1024.0*1024.0,
+        'B':     1.0, 'kB': 1024.0, 'mB': 1024.0*1024.0,
+                      'KB': 1024.0, 'MB': 1024.0*1024.0,
              }
     _max_mem = 0
     _max_rss = 0