The Gaudi Framework  master (57817a18)
Loading...
Searching...
No Matches
GaudiConfig2.semantics._DictHelper Class Reference
Inheritance diagram for GaudiConfig2.semantics._DictHelper:
Collaboration diagram for GaudiConfig2.semantics._DictHelper:

Public Member Functions

 __init__ (self, key_semantics, value_semantics)
 data (self)
 __len__ (self)
 __getitem__ (self, key)
 __setitem__ (self, key, value)
 __delitem__ (self, key)
 __iter__ (self)
 keys (self)
 items (self)
 values (self)
 __contains__ (self, key)
 get (self, key, default=None)
 update (self, otherMap)
 opt_value (self)
 __repr__ (self)

Public Attributes

 key_semantics = key_semantics
 value_semantics = value_semantics
 default = None
bool is_dirty = False
 data

Protected Attributes

dict _data = {}

Detailed Description

Definition at line 718 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiConfig2.semantics._DictHelper.__init__ ( self,
key_semantics,
value_semantics )

Definition at line 719 of file semantics.py.

719 def __init__(self, key_semantics, value_semantics):
720 self.key_semantics = key_semantics
721 self.value_semantics = value_semantics
722 self.default = None
723 self._data = {}
724 self.is_dirty = False
725

Member Function Documentation

◆ __contains__()

GaudiConfig2.semantics._DictHelper.__contains__ ( self,
key )

Definition at line 764 of file semantics.py.

764 def __contains__(self, key):
765 return self.key_semantics.store(key) in self.data
766

◆ __delitem__()

GaudiConfig2.semantics._DictHelper.__delitem__ ( self,
key )

Definition at line 744 of file semantics.py.

744 def __delitem__(self, key):
745 if not self.is_dirty:
746 raise RuntimeError("cannot remove elements from the default value")
747 self.data.__delitem__(self.key_semantics.store(key))
748

◆ __getitem__()

GaudiConfig2.semantics._DictHelper.__getitem__ ( self,
key )

Definition at line 733 of file semantics.py.

733 def __getitem__(self, key):
734 return self.value_semantics.load(
735 self.data.__getitem__(self.key_semantics.store(key))
736 )
737

◆ __iter__()

GaudiConfig2.semantics._DictHelper.__iter__ ( self)

Definition at line 749 of file semantics.py.

749 def __iter__(self):
750 for key in self.data:
751 yield self.key_semantics.load(key)
752

◆ __len__()

GaudiConfig2.semantics._DictHelper.__len__ ( self)

Definition at line 730 of file semantics.py.

730 def __len__(self):
731 return len(self.data)
732

◆ __repr__()

GaudiConfig2.semantics._DictHelper.__repr__ ( self)

Definition at line 787 of file semantics.py.

787 def __repr__(self):
788 return repr(self.data)
789
790

◆ __setitem__()

GaudiConfig2.semantics._DictHelper.__setitem__ ( self,
key,
value )

Definition at line 738 of file semantics.py.

738 def __setitem__(self, key, value):
739 self.is_dirty = True
740 self.data.__setitem__(
741 self.key_semantics.store(key), self.value_semantics.store(value)
742 )
743

◆ data()

GaudiConfig2.semantics._DictHelper.data ( self)

Definition at line 727 of file semantics.py.

727 def data(self):
728 return self._data if self.is_dirty else self.default
729

◆ get()

GaudiConfig2.semantics._DictHelper.get ( self,
key,
default = None )

Definition at line 767 of file semantics.py.

767 def get(self, key, default=None):
768 key = self.key_semantics.store(key)
769 if key in self.data:
770 return self.value_semantics.load(self.data[key])
771 return default
772

◆ items()

GaudiConfig2.semantics._DictHelper.items ( self)

Definition at line 756 of file semantics.py.

756 def items(self):
757 for key, value in self.data.items():
758 yield (self.key_semantics.load(key), self.value_semantics.load(value))
759

◆ keys()

GaudiConfig2.semantics._DictHelper.keys ( self)

Definition at line 753 of file semantics.py.

753 def keys(self):
754 return list(self)
755

◆ opt_value()

GaudiConfig2.semantics._DictHelper.opt_value ( self)

Definition at line 781 of file semantics.py.

781 def opt_value(self):
782 return {
783 self.key_semantics.opt_value(key): self.value_semantics.opt_value(value)
784 for key, value in self.data.items()
785 }
786

◆ update()

GaudiConfig2.semantics._DictHelper.update ( self,
otherMap )

Definition at line 776 of file semantics.py.

776 def update(self, otherMap):
777 self.is_dirty = True
778 for key, value in otherMap.items():
779 self.data[self.key_semantics.store(key)] = self.value_semantics.store(value)
780

◆ values()

GaudiConfig2.semantics._DictHelper.values ( self)

Definition at line 760 of file semantics.py.

760 def values(self):
761 for value in self.data.values():
762 yield self.value_semantics.load(value)
763

Member Data Documentation

◆ _data

dict GaudiConfig2.semantics._DictHelper._data = {}
protected

Definition at line 723 of file semantics.py.

◆ data

GaudiConfig2.semantics._DictHelper.data

Definition at line 731 of file semantics.py.

◆ default

GaudiConfig2.semantics._DictHelper.default = None

Definition at line 722 of file semantics.py.

◆ is_dirty

bool GaudiConfig2.semantics._DictHelper.is_dirty = False

Definition at line 724 of file semantics.py.

◆ key_semantics

GaudiConfig2.semantics._DictHelper.key_semantics = key_semantics

Definition at line 720 of file semantics.py.

◆ value_semantics

GaudiConfig2.semantics._DictHelper.value_semantics = value_semantics

Definition at line 721 of file semantics.py.


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