From: vsr Date: Wed, 7 Nov 2018 09:11:59 +0000 (+0300) Subject: Python 3 porting: IDLparser X-Git-Tag: V9_2_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a4638c96c6f7dc2481d05cfd3fea4446ac98b33f;p=modules%2Fkernel.git Python 3 porting: IDLparser --- diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index b2107353a..8cd3c91a8 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -21,12 +21,10 @@ # 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 @@ -116,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 + '"' @@ -135,7 +133,7 @@ class Tree: if self.name != '': s = '\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): @@ -143,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) @@ -540,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': @@ -837,7 +835,7 @@ def run(tree, args): #================================================== - if (os.path.exists(CatalogFileName)): + if (osp.exists(CatalogFileName)): print("Importing", CatalogFileName) C = Catalog(CatalogFileName) else: @@ -854,7 +852,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) @@ -869,7 +867,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()