Salome HOME
Updated copyright comment
[modules/kernel.git] / src / ModuleGenerator / IDLparser.py
index bc10283c5c9b2cf78b54847d32b4d6658b75b4b3..d0ed9d72d721293fdf664762976bbaddfee9d780 100644 (file)
@@ -1,5 +1,5 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-#  File   : IDLparser.py
-#  Module : SALOME
-
-import string, sys, fpformat, re, os
+import os
+import os.path as osp
+import re
 import xml.sax
-import pdb
 
 from xml.sax.handler import *
 from omniidl import idlast, idltype, idlvisitor, idlutil, output
@@ -39,7 +37,6 @@ common_data={"AUTHOR"     : "",
              "COMP_TYPE"  : "",
              "COMP_NAME"  : "",
              "COMP_UNAME" : "",
-             "COMP_MULT"  : "",
              "COMP_IMPL"  : ""
              }
 
@@ -117,7 +114,7 @@ class Tree:
     def output_xml(self, f, depth=0):
         d = depth
         if self.name != '':
-            s = string.ljust('', 4*depth)
+            s = ''.ljust(4*depth)
             s += '<' + self.name
             for k,v in list(self.attrs.items()):
               s += ' ' + k + '="' + v + '"'
@@ -136,7 +133,7 @@ class Tree:
         if self.name != '':
             s = '</' + self.name + '>\n'
             if len(self.childs) > 0 :
-                s = string.ljust('', 4*depth) + s
+                s = ''.ljust(4*depth) + s
             f.write(s)
 
     def Dump(self, levels=-1, depth=0):
@@ -144,7 +141,7 @@ class Tree:
 
         if levels == 0: return
 
-        s = string.ljust('', 4*depth)
+        s = ''.ljust(4*depth)
         print(s, self, self.content)
         for i in self.childs:
             i.Dump(levels-1, depth+1)
@@ -435,7 +432,6 @@ class Component(Tree):
         self.addNamedChild('component-author',     common_data["AUTHOR"])
         self.addNamedChild('component-version',    common_data["VERSION"])
         self.addNamedChild('component-comment',    'unknown')
-        self.addNamedChild('component-multistudy', common_data["COMP_MULT"])
         self.addNamedChild('component-impltype',   common_data["COMP_IMPL"])
         self.addNamedChild('component-icone',      common_data["ICON"])
         self.addNamedChild('constraint')
@@ -454,7 +450,7 @@ class Component(Tree):
 
         for i in ['component-username', 'component-author',
                   'component-type', 'component-icone', 'component-version',
-                  'component-multistudy', 'component-impltype', 'constraint']:
+                  'component-impltype', 'constraint']:
             ext = C.getChild(i)
             int = self.getChild(i)
             if int is None:
@@ -542,7 +538,7 @@ class Catalog(ContentHandler, Tree):
         self.buffer = ''
 
     def endElement(self, name):
-        self.buffer = string.join(string.split(self.buffer), ' ')
+        self.buffer = ' '.join(self.buffer.split())
         p = self.list[len(self.list)-1]
         p.content = self.buffer
         if name == 'component':
@@ -754,6 +750,9 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor):
     def visitStringType(self, type):
         self.currentType = "string"
 
+    def visitWStringType(self, type):
+        self.currentType = "wstring"
+
     def visitParameter(self, node):
         node.paramType().accept(self)
         if node.is_in():
@@ -831,7 +830,6 @@ def run(tree, args):
     common_data["COMP_NAME"]  = getParamValue("name",       "",                args)
     common_data["COMP_UNAME"] = getParamValue("username",   "",                args)
     common_data["COMP_TYPE"]  = getParamValue("type",       "OTHER",           args)
-    common_data["COMP_MULT"]  = getParamValue("multistudy", "1",               args)
     common_data["COMP_IMPL"]  = getParamValue("impltype",   "1",               args)
 
     print(common_data)
@@ -840,7 +838,7 @@ def run(tree, args):
 
     #==================================================
 
-    if (os.path.exists(CatalogFileName)):
+    if (osp.exists(CatalogFileName)):
         print("Importing", CatalogFileName)
         C = Catalog(CatalogFileName)
     else:
@@ -857,7 +855,7 @@ def run(tree, args):
     if remove_comp :
         C.removeComponent(remove_comp)
 
-    if (os.path.exists(CatalogFileName)):
+    if (osp.exists(CatalogFileName)):
         print("Updating", CatalogFileName)
         CatalogFileName_old = CatalogFileName + '_old'
         os.rename(CatalogFileName, CatalogFileName_old)
@@ -872,7 +870,7 @@ def run(tree, args):
     f.close()
 
     os.rename(CatalogFileName_new, CatalogFileName)
-    if ((CatalogFileName_old != "") & os.path.exists(CatalogFileName_old)):
+    if ((CatalogFileName_old != "") & osp.exists(CatalogFileName_old)):
         os.unlink(CatalogFileName_old)
 
     print()
@@ -880,5 +878,5 @@ def run(tree, args):
 
 if __name__ == "__main__":
     print()
-    print("Usage : omniidl -bIDLparser [-I<catalog files directory>]* -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,username=<component_username>][,multistudy=<component_multistudy>][,impltype=<implementation type : 0 (python), 1 (C++)>] <file.idl>")
+    print("Usage : omniidl -bIDLparser [-I<catalog files directory>]* -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,username=<component_username>][,impltype=<implementation type : 0 (python), 1 (C++)>] <file.idl>")
     print()