Back to index

salome-kernel  6.5.0
Public Member Functions | Public Attributes
IDLparser.Catalog Class Reference
Inheritance diagram for IDLparser.Catalog:
Inheritance graph
[legend]
Collaboration diagram for IDLparser.Catalog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def removeComponent
def startDocument
def startElement
def endElement
def characters
def mergeComponent
def mergeType
def addChild
def addNamedChild
def replaceChild
def insertFirstChild
def insertFirstNamedChild
def output_xml
def Dump
def parents
def getChild
def getNode
def __repr__
def merge
def mergeChilds
def setAttrib

Public Attributes

 buffer
 list
 name
 content
 key
 parent
 childs
 comments
 attrs

Detailed Description

Definition at line 475 of file IDLparser.py.


Constructor & Destructor Documentation

def IDLparser.Catalog.__init__ (   self,
  filename = None 
)

Definition at line 476 of file IDLparser.py.

00476 
00477     def __init__(self, filename = None):
00478         Tree.__init__(self)
00479         self.buffer = ''
00480         self.list = []
00481         if (filename):
00482             parser = xml.sax.make_parser()
00483             parser.setContentHandler(self)
00484             parser.parse(filename)
00485         else:
00486             t = self.addNamedChild('begin-catalog')
00487             t.addNamedChild('type-list')
00488             t.addNamedChild('component-list')
00489 
00490         n = self.getChild('begin-catalog')
00491         if n is None:
00492             error("Catalog.__init__ : No 'begin-catalog' is found!")
00493             return
00494         if n.getChild('path-prefix-list') is None:
00495             n.insertFirstNamedChild('path-prefix-list')
00496         if n.getChild('type-list') is None:
00497             p=n.childs.index(n.getChild('path-prefix-list'))
00498             n.childs.insert(p+1,Tree('type-list'))
00499         if n.getChild('component-list') is None:
00500             n.addNamedChild('component-list')


Member Function Documentation

def IDLparser.Tree.__repr__ (   self) [inherited]

Definition at line 184 of file IDLparser.py.

00184 
00185     def __repr__(self):
00186         s = '<'
00187         if self.name != '':
00188             s += self.name
00189         else:
00190             s +=  'None'
00191         s += '>'
00192         return s

def IDLparser.Tree.addChild (   self,
  tree 
) [inherited]

Definition at line 87 of file IDLparser.py.

00087 
00088     def addChild(self, tree):
00089         if tree is not None:
00090             self.childs.append(tree)
00091             tree.parent = self
00092         return tree

Here is the caller graph for this function:

def IDLparser.Tree.addNamedChild (   self,
  name,
  content = '' 
) [inherited]

Definition at line 93 of file IDLparser.py.

00093 
00094     def addNamedChild(self, name, content = ''):
00095         return self.addChild(Tree(name, content))

Here is the call graph for this function:

Here is the caller graph for this function:

def IDLparser.Catalog.characters (   self,
  ch 
)

Definition at line 554 of file IDLparser.py.

00554 
00555     def characters(self, ch):
00556         self.buffer += ch

def IDLparser.Tree.Dump (   self,
  levels = -1,
  depth = 0 
) [inherited]

Definition at line 141 of file IDLparser.py.

00141 
00142     def Dump(self, levels=-1, depth=0):
00143         #Dumps the tree contents
00144 
00145         if levels == 0: return
00146 
00147         s = string.ljust('', 4*depth)
00148         print s, self, self.content
00149         for i in self.childs:
00150             i.Dump(levels-1, depth+1)

def IDLparser.Catalog.endElement (   self,
  name 
)

Definition at line 545 of file IDLparser.py.

00545 
00546     def endElement(self, name):
00547         self.buffer = string.join(string.split(self.buffer), ' ')
00548         p = self.list[len(self.list)-1]
00549         p.content = self.buffer
00550         if name == 'component':
00551             p.key = p.getChild('component-name').content
00552         self.buffer = ''
00553         e = self.list.pop()

def IDLparser.Tree.getChild (   self,
  name,
  content = None 
) [inherited]

Definition at line 161 of file IDLparser.py.

00161 
00162     def getChild(self, name, content=None):
00163         # return child node with a given name
00164         # if content == None, don't compare contents
00165         for i in self.childs:
00166             if (i.name == name):
00167                 if (content is None) | (i.content == content):
00168                     return i
00169         return None

Here is the caller graph for this function:

def IDLparser.Tree.getNode (   self,
  name,
  content = '',
  depth = -1 
) [inherited]

Definition at line 170 of file IDLparser.py.

00170 
00171     def getNode(self, name, content='', depth=-1):
00172         # recursive search of a node with a given name
00173         # content == None, don't compare content
00174         if (self.name == name):
00175             if (content is None) | (self.content == content):
00176                 return self
00177 
00178         if (depth != 0):
00179             for i in self.childs:
00180                 n = i.getNode(name, content, depth-1)
00181                 if n:  return n
00182 
00183         return None

Here is the caller graph for this function:

def IDLparser.Tree.insertFirstChild (   self,
  tree 
) [inherited]

Definition at line 108 of file IDLparser.py.

00108 
00109     def insertFirstChild(self, tree):
00110         if tree is not None:
00111             self.childs.insert(0, tree)
00112         return tree

Here is the caller graph for this function:

def IDLparser.Tree.insertFirstNamedChild (   self,
  name,
  content = '' 
) [inherited]

Definition at line 113 of file IDLparser.py.

00113 
00114     def insertFirstNamedChild(self, name, content = ''):
00115         return self.insertFirstChild(Tree(name, content))

Here is the call graph for this function:

def IDLparser.Tree.merge (   self,
  t 
) [inherited]
def IDLparser.Tree.mergeChilds (   self,
  t,
  list 
) [inherited]

Definition at line 196 of file IDLparser.py.

00196 
00197     def mergeChilds(self, t, list):
00198         L_ext = t.getChild(list)
00199         L_int = self.getChild(list)
00200 
00201         L_merge = Tree(list)
00202 
00203         for i_ext in L_ext.childs:
00204             k_ext = i_ext.key
00205             if k_ext is None:  continue
00206             present = 0
00207 
00208             for i_int in L_int.childs:
00209                 k_int = i_int.key
00210                 if k_int is None:  continue
00211 
00212                 if (k_int == k_ext):
00213                     present = 1
00214                     break;
00215 
00216             if present :
00217                 i_int.merge(i_ext)
00218                 L_merge.addChild(i_int)
00219             else:
00220                 L_merge.addChild(i_ext)
00221 
00222         self.replaceChild(L_merge)

Here is the call graph for this function:

Here is the caller graph for this function:

def IDLparser.Catalog.mergeComponent (   self,
  comp 
)

Definition at line 557 of file IDLparser.py.

00557 
00558     def mergeComponent(self, comp):
00559 
00560         L_int = self.getNode('component-list')
00561         if   L_int is None:
00562             error("Catalog.mergeComponent : 'component-list' is not found")
00563             return
00564 
00565         i_ext = comp
00566         present = 0
00567         n_ext = i_ext.key
00568         for i_int in L_int.childs:
00569             if (i_int.key == n_ext):
00570                 present = 1
00571                 break;
00572 
00573         if present == 0:
00574             print '   add component', i_ext.getChild('component-name').content
00575             L_int.addChild(i_ext)
00576         else:
00577             print '   replace component', i_ext.getChild('component-name').content
00578             i_int.merge(i_ext)

Here is the call graph for this function:

def IDLparser.Catalog.mergeType (   self,
  type 
)

Definition at line 579 of file IDLparser.py.

00579 
00580     def mergeType(self, type):
00581       L_int = self.getNode('type-list')
00582       if L_int is None:
00583         error("Catalog.mergeType : 'type-list' is not found")
00584         return
00585       for t in L_int.childs:
00586         if t.attrs["name"] == type.attrs["name"]:
00587           t.merge(type)
00588           return
00589 
00590       L_int.addChild(type)

Here is the call graph for this function:

def IDLparser.Tree.output_xml (   self,
  f,
  depth = 0 
) [inherited]

Definition at line 116 of file IDLparser.py.

00116 
00117     def output_xml(self, f, depth=0):
00118         d = depth
00119         if self.name != '':
00120             s = string.ljust('', 4*depth)
00121             s += '<' + self.name
00122             for k,v in self.attrs.items():
00123               s += ' ' + k + '="' + v + '"'
00124             s += '>'
00125             if self.content != '':
00126                 s +=  self.content
00127             else:
00128                 if len(self.childs) > 0:
00129                     s += '\n'
00130             f.write(s)
00131             d +=  1
00132 
00133         for i in self.childs:
00134             i.output_xml(f, d)
00135 
00136         if self.name != '':
00137             s = '</' + self.name + '>\n'
00138             if len(self.childs) > 0 :
00139                 s = string.ljust('', 4*depth) + s
00140             f.write(s)

def IDLparser.Tree.parents (   self) [inherited]

Definition at line 151 of file IDLparser.py.

00151 
00152     def parents(self):
00153         #Returns list of the parents
00154         l = []
00155         p = self.parent
00156         while p:
00157             l.append(p)
00158             l.append(p.name)
00159             p = p.parent
00160         return l

def IDLparser.Catalog.removeComponent (   self,
  name 
)

Definition at line 501 of file IDLparser.py.

00501 
00502     def removeComponent(self, name):
00503         complist = self.getNode('component-list')
00504         idx = 0
00505         if complist is None:
00506             print "Catalog.removeComponent() : 'component-list' is not found"
00507             return
00508         for comp in complist.childs:
00509             cname = comp.getChild('component-name')
00510             if cname is not None:
00511                 if cname.content == name:
00512                     complist.childs.pop(idx)
00513                     print "Component " + name + " is removed"
00514             idx += 1

Here is the call graph for this function:

def IDLparser.Tree.replaceChild (   self,
  tree 
) [inherited]

Definition at line 96 of file IDLparser.py.

00096 
00097     def replaceChild(self, tree):
00098          if tree is not None:
00099             pos = 0
00100             for i in self.childs:
00101                 if (i.name == tree.name) & ((i.key is None) | (i.key == tree.key)):
00102                     self.childs.pop(pos)
00103                     self.childs.insert(pos, tree)
00104                     return tree
00105                 pos += 1
00106 
00107          return self.addChild(tree)

Here is the call graph for this function:

Here is the caller graph for this function:

def IDLparser.Tree.setAttrib (   self,
  name,
  value 
) [inherited]

Definition at line 223 of file IDLparser.py.

00223 
00224     def setAttrib(self, name,value):
00225       self.attrs[name]=value
00226 
00227 
00228 #--------------------------------------------------
00229 # implements parameter tree
#--------------------------------------------------

Here is the caller graph for this function:

Definition at line 515 of file IDLparser.py.

00515 
00516     def startDocument(self):
00517         self.list.append(self)

def IDLparser.Catalog.startElement (   self,
  name,
  attrs 
)

Definition at line 518 of file IDLparser.py.

00518 
00519     def startElement(self, name, attrs):
00520         p = self.list[len(self.list)-1]
00521         if name == 'component':
00522             e = p.addChild(Component())
00523         elif name == 'component-interface-name':
00524             e = p.addNamedChild(name)
00525         elif name == 'component-service':
00526             e = p.addChild(Service())
00527         elif name == 'inParameter':
00528             e = p.addChild(parameter(mode='in'))
00529         elif name == 'outParameter':
00530             e = p.addChild(parameter(mode='out'))
00531         elif name == 'sequence':
00532             e = p.addChild(SeqType(attrs["name"],attrs["content"]))
00533         elif name == 'objref':
00534             e = p.addChild(ObjType(attrs["name"]))
00535         elif name == 'struct':
00536             e = p.addChild(StructType(attrs["name"]))
00537         elif name == 'type':
00538             e = p.addChild(Type(attrs["name"],attrs["kind"]))
00539         elif name == 'member':
00540             e = p.addChild(Member(attrs["name"],attrs["type"]))
00541         else:
00542             e = p.addNamedChild(name)
00543         self.list.append(e)
00544         self.buffer = ''


Member Data Documentation

IDLparser.Tree.attrs [inherited]

Definition at line 85 of file IDLparser.py.

Definition at line 478 of file IDLparser.py.

IDLparser.Tree.childs [inherited]

Reimplemented in IDLparser.ObjType, and IDLparser.StructType.

Definition at line 83 of file IDLparser.py.

Definition at line 84 of file IDLparser.py.

Definition at line 80 of file IDLparser.py.

IDLparser.Tree.key [inherited]

Definition at line 81 of file IDLparser.py.

Definition at line 479 of file IDLparser.py.

IDLparser.Tree.name [inherited]

Definition at line 79 of file IDLparser.py.

IDLparser.Tree.parent [inherited]

Definition at line 82 of file IDLparser.py.


The documentation for this class was generated from the following file: