The Gaudi Framework  master (adcf1ca6)
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 631 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 632 of file semantics.py.

632 def __init__(self, key_semantics, value_semantics):
633 self.key_semantics = key_semantics
634 self.value_semantics = value_semantics
635 self.default = None
636 self._data = {}
637 self.is_dirty = False
638

Member Function Documentation

◆ __contains__()

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

Definition at line 677 of file semantics.py.

677 def __contains__(self, key):
678 return self.key_semantics.store(key) in self.data
679

◆ __delitem__()

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

Definition at line 657 of file semantics.py.

657 def __delitem__(self, key):
658 if not self.is_dirty:
659 raise RuntimeError("cannot remove elements from the default value")
660 self.data.__delitem__(self.key_semantics.store(key))
661

◆ __getitem__()

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

Definition at line 646 of file semantics.py.

646 def __getitem__(self, key):
647 return self.value_semantics.load(
648 self.data.__getitem__(self.key_semantics.store(key))
649 )
650

◆ __iter__()

GaudiConfig2.semantics._DictHelper.__iter__ ( self)

Definition at line 662 of file semantics.py.

662 def __iter__(self):
663 for key in self.data:
664 yield self.key_semantics.load(key)
665

◆ __len__()

GaudiConfig2.semantics._DictHelper.__len__ ( self)

Definition at line 643 of file semantics.py.

643 def __len__(self):
644 return len(self.data)
645

◆ __repr__()

GaudiConfig2.semantics._DictHelper.__repr__ ( self)

Definition at line 700 of file semantics.py.

700 def __repr__(self):
701 return repr(self.data)
702
703

◆ __setitem__()

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

Definition at line 651 of file semantics.py.

651 def __setitem__(self, key, value):
652 self.is_dirty = True
653 self.data.__setitem__(
654 self.key_semantics.store(key), self.value_semantics.store(value)
655 )
656

◆ data()

GaudiConfig2.semantics._DictHelper.data ( self)

Definition at line 640 of file semantics.py.

640 def data(self):
641 return self._data if self.is_dirty else self.default
642

◆ get()

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

Definition at line 680 of file semantics.py.

680 def get(self, key, default=None):
681 key = self.key_semantics.store(key)
682 if key in self.data:
683 return self.value_semantics.load(self.data[key])
684 return default
685

◆ items()

GaudiConfig2.semantics._DictHelper.items ( self)

Definition at line 669 of file semantics.py.

669 def items(self):
670 for key, value in self.data.items():
671 yield (self.key_semantics.load(key), self.value_semantics.load(value))
672

◆ keys()

GaudiConfig2.semantics._DictHelper.keys ( self)

Definition at line 666 of file semantics.py.

666 def keys(self):
667 return list(self)
668

◆ opt_value()

GaudiConfig2.semantics._DictHelper.opt_value ( self)

Definition at line 694 of file semantics.py.

694 def opt_value(self):
695 return {
696 self.key_semantics.opt_value(key): self.value_semantics.opt_value(value)
697 for key, value in self.data.items()
698 }
699

◆ update()

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

Definition at line 689 of file semantics.py.

689 def update(self, otherMap):
690 self.is_dirty = True
691 for key, value in otherMap.items():
692 self.data[self.key_semantics.store(key)] = self.value_semantics.store(value)
693

◆ values()

GaudiConfig2.semantics._DictHelper.values ( self)

Definition at line 673 of file semantics.py.

673 def values(self):
674 for value in self.data.values():
675 yield self.value_semantics.load(value)
676

Member Data Documentation

◆ _data

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

Definition at line 636 of file semantics.py.

◆ data

GaudiConfig2.semantics._DictHelper.data

Definition at line 644 of file semantics.py.

◆ default

GaudiConfig2.semantics._DictHelper.default = None

Definition at line 635 of file semantics.py.

◆ is_dirty

bool GaudiConfig2.semantics._DictHelper.is_dirty = False

Definition at line 637 of file semantics.py.

◆ key_semantics

GaudiConfig2.semantics._DictHelper.key_semantics = key_semantics

Definition at line 633 of file semantics.py.

◆ value_semantics

GaudiConfig2.semantics._DictHelper.value_semantics = value_semantics

Definition at line 634 of file semantics.py.


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