CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Node.py
Go to the documentation of this file.
1 class Node(object):
2  def __init__( self ):
3  """__init__
4  """
5  self.__dict__.setdefault('nodeid',0)
6  self.__dict__.setdefault('nodelabel','ROOT')
7  self.__dict__.setdefault('lft',0)
8  self.__dict__.setdefault('rgt',0)
9  self.__dict__.setdefault('parentid',0)
10  self.__dict__.setdefault('globalsince',0)
11  self.__dict__.setdefault('globaltill',0)
12  self.__dict__.setdefault('tagid',0)
13  def __repr__( self ):
14  """__repr__
15  """
16  return self.__dict__.__repr__()
17  def __setattr__( self, name, value ):
18  if not name in self.__dict__:
19  raise AttributeError("Unknown attribute "+name)
20  self.__dict__[name]=value
21  def __getattr__( self, name ):
22  if not name in self.__dict__:
23  raise AttributeError("Unknown attribute "+name)
24  return self.__dict__[name]
25  def empty( self ):
26  if self.__dict__['nodelabel']=='':
27  return True
28  return False
29 class LeafNode(Node):
30  """The leaf node
31  """
32  def __init__( self ):
33  """__init__
34  """
35  super(Node,self).__init__()
36  super(Node,self).__setattr__( 'tagid',0 )
37  self.__dict__.setdefault('tagname','')
38  #self.__dict__.setdefault('tagid',0)
39  self.__dict__.setdefault('pfn','')
40  self.__dict__.setdefault('recordname','')
41  self.__dict__.setdefault('objectname','')
42  self.__dict__.setdefault('labelname','')
43  def __repr__( self ):
44  """__repr__
45  """
46  if self.tagname=='':
47  return ''
48  return self.__dict__.__repr__()
49 if __name__ == "__main__":
50  node=Node()
51  node.nodeid=1
52  print node.nodeid
53  print node.nodelabel
54  print node.lft
55  try:
56  node.foreign='a'
57  except AttributeError:
58  print 'caught right exception'
59  except Exception, er:
60  print 'unexpected error'
61  print str(er)
62  leaf=LeafNode()
63  print leaf.__class__.__name__,'isLeaf',str(leaf.tagid)
64  print node.__class__.__name__,'isLeaf',str(node.tagid)
def __repr__
Definition: Node.py:13
def __init__
Definition: Node.py:2
def __setattr__
Definition: Node.py:17
def __getattr__
Definition: Node.py:21
list object
Definition: dbtoconf.py:77