ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.hanwriter.HanOutput Class Reference
Inheritance diagram for python.hanwriter.HanOutput:
Collaboration diagram for python.hanwriter.HanOutput:

Public Member Functions

def __init__ (self, name, algorithm=None, father=None, annotations={}, attributes={})
 
def getAlgorithm (self)
 
def addOutput (self, name, algorithm, annotations, attributes)
 
def getOutputPath (self, append=None, delimiter="/")
 
def tohan (self, encoding=None)
 
def toprettyhan (self, indent="\t", newl="\n", encoding=None)
 
def writehan (self, writer, indent="", addindent="", newl="")
 
def appendChild (self, child)
 
def setAttribute (self, key, attribute)
 
def removeAttribute (self, key)
 
def getAttribute (self, key)
 
def getSubNode (self, name, nodetype)
 
def __str__ (self)
 

Public Attributes

 acceptChild
 
 nodeType
 
 father
 
 subnodes
 
 attributes
 
 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 439 of file hanwriter.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 453 of file hanwriter.py.

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

Member Function Documentation

◆ __str__()

def python.hanwriter.Node.__str__ (   self)
inherited

Definition at line 192 of file hanwriter.py.

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

◆ addOutput()

def 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 483 of file hanwriter.py.

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

◆ appendChild()

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

Definition at line 128 of file hanwriter.py.

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

◆ getAlgorithm()

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

Definition at line 470 of file hanwriter.py.

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

◆ getAttribute()

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

Definition at line 170 of file hanwriter.py.

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

◆ getOutputPath()

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

Definition at line 495 of file hanwriter.py.

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

◆ getSubNode()

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

Definition at line 182 of file hanwriter.py.

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

◆ removeAttribute()

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

Definition at line 158 of file hanwriter.py.

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

◆ setAttribute()

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

Definition at line 147 of file hanwriter.py.

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

◆ tohan()

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

Definition at line 76 of file hanwriter.py.

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

◆ toprettyhan()

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

Definition at line 87 of file hanwriter.py.

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

◆ writehan()

def 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 107 of file hanwriter.py.

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

Member Data Documentation

◆ acceptChild

python.hanwriter.HanOutput.acceptChild

Definition at line 458 of file hanwriter.py.

◆ attributes

python.hanwriter.Node.attributes
inherited

Definition at line 67 of file hanwriter.py.

◆ father

python.hanwriter.HanOutput.father

Definition at line 462 of file hanwriter.py.

◆ name

python.hanwriter.Node.name
inherited

Definition at line 71 of file hanwriter.py.

◆ nodeType

python.hanwriter.HanOutput.nodeType

Definition at line 459 of file hanwriter.py.

◆ subnodes

python.hanwriter.Node.subnodes
inherited

Definition at line 66 of file hanwriter.py.


The documentation for this class was generated from the following file:
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11