ATLAS Offline Software
Loading...
Searching...
No Matches
python.hanwriter.HanLimit Class Reference
Inheritance diagram for python.hanwriter.HanLimit:
Collaboration diagram for python.hanwriter.HanLimit:

Public Member Functions

 __init__ (self, name, warning, error)
 tohan (self, encoding=None)
 toprettyhan (self, indent="\t", newl="\n", encoding=None)
 writehan (self, writer, indent="", addindent="", newl="")
 appendChild (self, child)
 setAttribute (self, key, attribute)
 removeAttribute (self, key)
 getAttribute (self, key)
 getSubNode (self, name, nodetype)
 __str__ (self)

Public Attributes

list subnodes = None
dict attributes = None
list acceptChild
 nodeType = Node.UNKNOWN
 name = name

Detailed Description

The han representation of a limit for a HanThreshold

Definition at line 327 of file hanwriter.py.

Constructor & Destructor Documentation

◆ __init__()

python.hanwriter.HanLimit.__init__ ( self,
name,
warning,
error )
Creates a han limit object

Definition at line 336 of file hanwriter.py.

336 def __init__(self, name, warning, error):
337 """
338 Creates a han limit object
339 """
340 Node.__init__(self, name)
341 self.nodeType = Node.LIMIT
342 self.acceptChild = []
343 self.setAttribute('warning', warning)
344 self.setAttribute('error', error)
345
346# Class for threshold
347# This class implements the han representation of a DQThreshold
348
349

Member Function Documentation

◆ __str__()

python.hanwriter.Node.__str__ ( self)
inherited

Definition at line 190 of file hanwriter.py.

190 def __str__(self):
191 return "HanNode: "+self.name+" ("+DQHanConfMaker._get_NodeType(self.nodeType)+") Attributes:"+str(self.attributes)+" SubNodes: "+str(self.subnodes)
192
193
194# HanHistogram class
195# This class represents the configuration for a histogram

◆ appendChild()

python.hanwriter.Node.appendChild ( self,
child )
inherited
Add a sub node to this node

Definition at line 126 of file hanwriter.py.

126 def appendChild(self, child):
127 """
128 Add a sub node to this node
129 """
130 try:
131 if child.nodeType not in self.acceptChild:
132 msg = " Node: "+DQHanConfMaker._get_NodeType(self.nodeType)
133 msg += " Cannot have a child of type:", child.nodeType
134 raise HanCannotCreateConf(msg)
135 except Exception:
136 raise HanCannotCreateConf(
137 "Object:"+str(child)+" is not a valid Node")
138 if not self.subnodes:
139 self.subnodes = []
140 self.subnodes += [child]
141

◆ getAttribute()

python.hanwriter.Node.getAttribute ( self,
key )
inherited
Gets the attribute identified by the key, None if not found

Definition at line 168 of file hanwriter.py.

168 def getAttribute(self, key):
169 """
170 Gets the attribute identified by the key, None if not found
171 """
172 if self.attributes and key in self.attributes:
173 return self.attributes[key]
174 return None

◆ getSubNode()

python.hanwriter.Node.getSubNode ( self,
name,
nodetype )
inherited
Returns the sub-node identified by name and nodetype

Definition at line 180 of file hanwriter.py.

180 def getSubNode(self, name, nodetype):
181 """
182 Returns the sub-node identified by name and nodetype
183 """
184 if self.subnodes:
185 for sn in self.subnodes:
186 if sn.nodeType == nodetype and sn.name == name:
187 return sn
188 return None
189

◆ removeAttribute()

python.hanwriter.Node.removeAttribute ( self,
key )
inherited
Removes attribute identified by key

Definition at line 156 of file hanwriter.py.

156 def removeAttribute(self, key):
157 """
158 Removes attribute identified by key
159 """
160 if self.attributes and key in self.attributes:
161 del self.attributes[key]
162 return True
163 return False

◆ setAttribute()

python.hanwriter.Node.setAttribute ( self,
key,
attribute )
inherited
The attribute identified by key is added to this node

Definition at line 145 of file hanwriter.py.

145 def setAttribute(self, key, attribute):
146 """
147 The attribute identified by key is added to this node
148 """
149 if not self.attributes:
150 self.attributes = {}
151 self.attributes[key] = attribute

◆ tohan()

python.hanwriter.Node.tohan ( self,
encoding = None )
inherited
convert the object in a valid han script block

Definition at line 75 of file hanwriter.py.

75 def tohan(self, encoding=None):
76 """
77 convert the object in a valid han script block
78 """
79 return self.toprettyhan("", "", encoding)
80

◆ toprettyhan()

python.hanwriter.Node.toprettyhan ( self,
indent = "\t",
newl = "\n",
encoding = None )
inherited
convert the object in a formatted han string

Definition at line 86 of file hanwriter.py.

86 def toprettyhan(self, indent="\t", newl="\n", encoding=None):
87 """
88 convert the object in a formatted han string
89 """
90 # restore the following in a future tdaq release
91 # writer = DQHanConfMaker._get_StringIO()
92 import io
93 writer = io.StringIO()
94 if encoding is not None:
95 import codecs
96 writer = codecs.lookup(encoding)[3](writer)
97 self.writehan(writer, "", indent, newl)
98 return writer.getvalue()
99

◆ writehan()

python.hanwriter.Node.writehan ( self,
writer,
indent = "",
addindent = "",
newl = "" )
inherited
Converts the object in a han string and writes it in the writer object

Definition at line 105 of file hanwriter.py.

105 def writehan(self, writer, indent="", addindent="", newl=""):
106 """
107 Converts the object in a han string and writes it in the writer object
108 """
109 writer.write(
110 indent+DQHanConfMaker._get_NodeType(self.nodeType)+" "+self.name)
111 # if it is a document do not need to add { }
112 if self.nodeType != Node.DOCUMENT:
113 writer.write(" { %s" % (newl))
114 if self.attributes:
115 for key, attribute in self.attributes.items():
116 writer.write("%s %s = %s%s" % (indent, key, attribute, newl))
117 if self.subnodes:
118 for node in self.subnodes:
119 node.writehan(writer, indent+addindent, addindent, newl)
120 if self.nodeType != Node.DOCUMENT:
121 writer.write("%s}%s" % (indent, newl))
122

Member Data Documentation

◆ acceptChild

list python.hanwriter.Node.acceptChild
inherited
Initial value:
= [Node.ALGORITHM, Node.DIR, Node.DOCUMENT, Node.HIST, Node.OUTPUT,
Node.REFERENCE, Node.THRESHOLD, Node.LIMIT, Node.COMPALG]

Definition at line 67 of file hanwriter.py.

◆ attributes

python.hanwriter.Node.attributes = None
inherited

Definition at line 66 of file hanwriter.py.

◆ name

python.hanwriter.Node.name = name
inherited

Definition at line 70 of file hanwriter.py.

◆ nodeType

python.hanwriter.Node.nodeType = Node.UNKNOWN
inherited

Definition at line 69 of file hanwriter.py.

◆ subnodes

python.hanwriter.Node.subnodes = None
inherited

Definition at line 65 of file hanwriter.py.


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