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

Public Member Functions

 __init__ (self, top_level_algorithm='WorstCaseSummary')
 addOutput (self, name, algorithm, annotations={}, attributes={})
 getAlgorithm (self, name)
 getReference (self, name)
 addSubDir (self, name)
 addHistogram (self, histogram, algorithm, annotations={}, output=DQHanConfMaker._default_output, attributes={})
 getSubDir (self, name)
 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)
 getOutputPath (self, append=None, delimiter="/")

Public Attributes

 root_output_level = HanOutput('top_level', top_level_algorithm)
list subnodes = None
dict attributes = None
list acceptChild
 nodeType = Node.UNKNOWN
 name = name
 father = father

Detailed Description

Class representing a han document

Definition at line 509 of file hanwriter.py.

Constructor & Destructor Documentation

◆ __init__()

python.hanwriter.Document.__init__ ( self,
top_level_algorithm = 'WorstCaseSummary' )
Creates an empty han document with a top level output

Definition at line 516 of file hanwriter.py.

516 def __init__(self, top_level_algorithm='WorstCaseSummary'):
517 """
518 Creates an empty han document with a top level output
519 """
520 HanDir.__init__(self, '')
521 HanOutput.__init__(self, '')
522 self.nodeType = Node.DOCUMENT
523 self.acceptChild = [Node.ALGORITHM, Node.DIR, Node.HIST, Node.OUTPUT, Node.REFERENCE, Node.THRESHOLD,
524 Node.COMPALG]
525 self.root_output_level = HanOutput('top_level', top_level_algorithm)
526 self.appendChild(self.root_output_level)

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

◆ addHistogram()

python.hanwriter.HanDir.addHistogram ( self,
histogram,
algorithm,
annotations = {},
output = DQHanConfMaker._default_output,
attributes = {} )
inherited
Adds to the directory a histogram specifying the histogram name, the algorithm and the output path.

Definition at line 416 of file hanwriter.py.

416 def addHistogram(self, histogram, algorithm, annotations={}, output=DQHanConfMaker._default_output, attributes={}):
417 """
418 Adds to the directory a histogram specifying the histogram name, the algorithm and the output path.
419 """
420 histo = HanHistogram(histogram, algorithm,
421 annotations, output, attributes)
422 self.appendChild(histo)
423 return histo

◆ addOutput()

python.hanwriter.Document.addOutput ( self,
name,
algorithm,
annotations = {},
attributes = {} )
Adds a sub output element with name and algorithm

Reimplemented from python.hanwriter.HanOutput.

Definition at line 534 of file hanwriter.py.

534 def addOutput(self, name, algorithm, annotations={}, attributes={}):
535 """
536 Adds a sub output element with name and algorithm
537 """
538 # forward to root region
539 return HanOutput.addOutput(self.root_output_level, name, algorithm, annotations, attributes)

◆ addSubDir()

python.hanwriter.HanDir.addSubDir ( self,
name )
inherited
Adds a subdirectory called name to the current directory and returns the newly created sub directory

Definition at line 401 of file hanwriter.py.

401 def addSubDir(self, name):
402 """
403 Adds a subdirectory called name to the current directory and returns the newly created sub directory
404 """
405 subdir = HanDir(name)
406 self.appendChild(subdir)
407 return subdir

◆ 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.Document.getAlgorithm ( self,
name )
retrieves the algorithm han object associated with name

Reimplemented from python.hanwriter.HanOutput.

Definition at line 544 of file hanwriter.py.

544 def getAlgorithm(self, name):
545 """
546 retrieves the algorithm han object associated with name
547 """
548 return self.getSubNode(name, Node.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 = "/" )
inherited
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

◆ getReference()

python.hanwriter.Document.getReference ( self,
name )
retrieves the han reference associated with name

Definition at line 553 of file hanwriter.py.

553 def getReference(self, name):
554 """
555 retrieves the han reference associated with name
556 """
557 return self.getSubNode(name, Node.REFERENCE)
558
559
560# Add a DQParameter object to the HanDocument
561# @param handocument: the document containing the configuration @c handocument: a HanDocument object
562# @param dqparameter: the DQParameter object @c dqparameter: a DQParameter object
563# @param output: the output element for the result
564# @note: This function is used internally and should not be used by users of this module

◆ getSubDir()

python.hanwriter.HanDir.getSubDir ( self,
name )
inherited
returns the sub-directory called name

Definition at line 427 of file hanwriter.py.

427 def getSubDir(self, name):
428 """
429 returns the sub-directory called name
430 """
431 return self.getSubNode(name, Node.DIR)
432
433# Class for han output
434# This class implements the han output
435
436

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

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.

◆ root_output_level

python.hanwriter.Document.root_output_level = HanOutput('top_level', top_level_algorithm)

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