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

Public Member Functions

def __init__ (self, dic={}, key_wrapper=None)
 
def __missing__ (self, key, wrap=True)
 
def __setitem__ (self, key, value, wrap=True)
 
def to_dict (self)
 
def __repr__ (self, level=0)
 

Public Attributes

 default_factory
 
 key_wrapper
 

Private Member Functions

def _repr_pretty_ (self, p, cycle)
 

Detailed Description

Definition at line 22 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

Constructor & Destructor Documentation

◆ __init__()

def python.utils.TreeDict.__init__ (   self,
  dic = {},
  key_wrapper = None 
)

Definition at line 23 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

23  def __init__(self, dic = {}, key_wrapper=None):
24  super(defaultdict,self).__init__(dic)
25  self.default_factory = tree(key_wrapper)
26  self.key_wrapper = key_wrapper

Member Function Documentation

◆ __missing__()

def python.utils.TreeDict.__missing__ (   self,
  key,
  wrap = True 
)

Definition at line 27 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

27  def __missing__(self, key, wrap=True):
28  if self.default_factory is None: raise KeyError((key,))
29  if wrap and self.key_wrapper:
30  key = self.key_wrapper(key)
31  if len(key) == 1:
32  return self.__missing__(key[0], wrap=False)
33  else:
34  return self[key[0]][key[1]]
35  self[key] = value = self.default_factory()
36  return value

◆ __repr__()

def python.utils.TreeDict.__repr__ (   self,
  level = 0 
)

Definition at line 48 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

48  def __repr__(self, level=0):
49  ret = u''
50  items = list(self.items())
51  len_key = 0
52  for i, (key, val) in enumerate(items):
53  LS = BRANCH if i < len(items)-1 else TAIL
54  ret += SPACE(' '*len_key)*level + LS(key.ljust(len_key)) + '\n'
55  if isinstance(val, TreeDict):
56  ret += val.__repr__(level+1)
57  else:
58  ret += SPACE(' '*len_key)*(level+1) + LS(str(val).ljust(len_key)) + '\n'
59  return ret

◆ __setitem__()

def python.utils.TreeDict.__setitem__ (   self,
  key,
  value,
  wrap = True 
)

Definition at line 37 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

37  def __setitem__(self, key, value, wrap=True):
38  if wrap and self.key_wrapper:
39  key = self.key_wrapper(key)
40  if len(key) == 1:
41  self.__setitem__(key[0], value, wrap=False)
42  else:
43  self[key[0]][key[1]] = value
44  else:
45  super(defaultdict, self).__setitem__(key, value)

◆ _repr_pretty_()

def python.utils.TreeDict._repr_pretty_ (   self,
  p,
  cycle 
)
private

Definition at line 60 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

60  def _repr_pretty_(self, p, cycle):
61  return p.text(repr(self))

◆ to_dict()

def python.utils.TreeDict.to_dict (   self)

Definition at line 46 of file Reconstruction/RecExample/RecExOnline/python/utils.py.

46  def to_dict(self):
47  return dict((key, val.to_dict()) if isinstance(val, TreeDict) else (key, val) for key, val in self.items())

Member Data Documentation

◆ default_factory

python.utils.TreeDict.default_factory

◆ key_wrapper

python.utils.TreeDict.key_wrapper

The documentation for this class was generated from the following file:
tree
TChain * tree
Definition: tile_monitor.h:30
PyAthena::repr
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
Definition: PyAthenaUtils.cxx:106
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.Bindings.__setitem__
__setitem__
Definition: Control/AthenaPython/python/Bindings.py:771
str
Definition: BTagTrackIpAccessor.cxx:11