Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / blocFissure / gmu / putName.py
index dadd6f22f2b55f2cf7b316a22bf4df8630a1b6d6..1be0d00fffb5b19e0923c213c0790a3da299797a 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2014-2021  EDF R&D
+# Copyright (C) 2014-2022  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
@@ -22,7 +22,7 @@
 #import logging
 from .geomsmesh import smesh
 
-def putName (objmesh, name, i_suff=-1, i_pref=-1):
+def putName (objmesh, name, i_suff=-1, i_pref=None):
   """Nommage des objets mesh
 
   @objmesh objet à nommer
@@ -31,15 +31,20 @@ def putName (objmesh, name, i_suff=-1, i_pref=-1):
   @i_pref un éventuel préfixe
   """
 
-  #logging.info("putName pour %s - i_suff=%d, i_pref=%d", name, i_suff, i_pref)
+  #texte = "Name = {}, i_suff = {}, i_pref = {}".format(name,i_suff,i_pref)
+  #print(texte)
+  #logging.info(texte)
   # suffixe éventuel :
-  if i_suff >= 0:
+  if ( i_suff >= 0 ):
     suffixe = "_{}".format(i_suff)
     name += suffixe
 
   # préfixe éventuel :
-  if i_pref >= 0:
-    prefixe = "Cas{:02d}_".format(i_pref)
+  if ( i_pref is not None):
+    if isinstance(i_pref,int):
+      prefixe = "Cas{:02d}_".format(i_pref)
+    else:
+      prefixe = "{}_".format(i_pref)
     name = prefixe + name
   #logging.info("Au final : %s", name)