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

Public Member Functions

 __init__ (self, name, algorithm=None, father=None, annotations={}, attributes={})
 getAlgorithm (self)
 addOutput (self, name, algorithm, annotations, attributes)
 getOutputPath (self, append=None, delimiter="/")
 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

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

Detailed Description

Class representing a output element
A han output element is a Node with sub nodes of type output and with the optional attribute algorithm
attribute:
    - father: the HanOutput that contains this HanOutput

Definition at line 437 of file hanwriter.py.

Constructor & Destructor Documentation

◆ __init__()

python.hanwriter.HanOutput.__init__ ( self,
name,
algorithm = None,
father = None,
annotations = {},
attributes = {} )
Creates an output han element

Definition at line 451 of file hanwriter.py.

451 def __init__(self, name, algorithm=None, father=None, annotations={}, attributes={}):
452 """
453 Creates an output han element
454 """
455 Node.__init__(self, name)
456 self.acceptChild = [Node.OUTPUT]
457 self.nodeType = Node.OUTPUT
458 if algorithm:
459 self.setAttribute('algorithm', algorithm)
460 self.father = father
461 if 'Weight' in attributes:
462 self.setAttribute('weight', attributes['Weight'][1])
463 for annotation in annotations:
464 self.setAttribute(annotation, annotations[annotation])
465

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

◆ addOutput()

python.hanwriter.HanOutput.addOutput ( self,
name,
algorithm,
annotations,
attributes )
Adds a sub output element with name and algorithm

Reimplemented in python.hanwriter.Document.

Definition at line 481 of file hanwriter.py.

481 def addOutput(self, name, algorithm, annotations, attributes):
482 """
483 Adds a sub output element with name and algorithm
484 """
485 subnode = HanOutput(name, algorithm, self, annotations, attributes)
486 self.appendChild(subnode)
487 return subnode

◆ 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

◆ getAlgorithm()

python.hanwriter.HanOutput.getAlgorithm ( self)
Gets the algorithm attribute

Reimplemented in python.hanwriter.Document.

Definition at line 468 of file hanwriter.py.

468 def getAlgorithm(self):
469 """
470 Gets the algorithm attribute
471 """
472 if 'algorithm' in self.attributes:
473 return self.getAttribute('algorithm')

◆ 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

◆ getOutputPath()

python.hanwriter.HanOutput.getOutputPath ( self,
append = None,
delimiter = "/" )
Creates the complete path of this output directory

Definition at line 493 of file hanwriter.py.

493 def getOutputPath(self, append=None, delimiter="/"):
494 """
495 Creates the complete path of this output directory
496 """
497 name = self.name
498 if append:
499 name = name + append
500 if self.father:
501 name = self.father.getOutputPath(delimiter+name, delimiter)
502 return name
503
504# Class document
505# This class represents the han document.
506# This class is a set of nodes
507
508

◆ 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.

◆ father

python.hanwriter.HanOutput.father = father

Definition at line 460 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: