The Gaudi Framework  master (3415b466)
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 634 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 635 of file semantics.py.

635 def __init__(self, key_semantics, value_semantics):
636 self.key_semantics = key_semantics
637 self.value_semantics = value_semantics
638 self.default = None
639 self._data = {}
640 self.is_dirty = False
641

Member Function Documentation

◆ __contains__()

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

Definition at line 680 of file semantics.py.

680 def __contains__(self, key):
681 return self.key_semantics.store(key) in self.data
682

◆ __delitem__()

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

Definition at line 660 of file semantics.py.

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

◆ __getitem__()

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

Definition at line 649 of file semantics.py.

649 def __getitem__(self, key):
650 return self.value_semantics.load(
651 self.data.__getitem__(self.key_semantics.store(key))
652 )
653

◆ __iter__()

GaudiConfig2.semantics._DictHelper.__iter__ ( self)

Definition at line 665 of file semantics.py.

665 def __iter__(self):
666 for key in self.data:
667 yield self.key_semantics.load(key)
668

◆ __len__()

GaudiConfig2.semantics._DictHelper.__len__ ( self)

Definition at line 646 of file semantics.py.

646 def __len__(self):
647 return len(self.data)
648

◆ __repr__()

GaudiConfig2.semantics._DictHelper.__repr__ ( self)

Definition at line 703 of file semantics.py.

703 def __repr__(self):
704 return repr(self.data)
705
706

◆ __setitem__()

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

Definition at line 654 of file semantics.py.

654 def __setitem__(self, key, value):
655 self.is_dirty = True
656 self.data.__setitem__(
657 self.key_semantics.store(key), self.value_semantics.store(value)
658 )
659

◆ data()

GaudiConfig2.semantics._DictHelper.data ( self)

Definition at line 643 of file semantics.py.

643 def data(self):
644 return self._data if self.is_dirty else self.default
645

◆ get()

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

Definition at line 683 of file semantics.py.

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

◆ items()

GaudiConfig2.semantics._DictHelper.items ( self)

Definition at line 672 of file semantics.py.

672 def items(self):
673 for key, value in self.data.items():
674 yield (self.key_semantics.load(key), self.value_semantics.load(value))
675

◆ keys()

GaudiConfig2.semantics._DictHelper.keys ( self)

Definition at line 669 of file semantics.py.

669 def keys(self):
670 return list(self)
671

◆ opt_value()

GaudiConfig2.semantics._DictHelper.opt_value ( self)

Definition at line 697 of file semantics.py.

697 def opt_value(self):
698 return {
699 self.key_semantics.opt_value(key): self.value_semantics.opt_value(value)
700 for key, value in self.data.items()
701 }
702

◆ update()

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

Definition at line 692 of file semantics.py.

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

◆ values()

GaudiConfig2.semantics._DictHelper.values ( self)

Definition at line 676 of file semantics.py.

676 def values(self):
677 for value in self.data.values():
678 yield self.value_semantics.load(value)
679

Member Data Documentation

◆ _data

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

Definition at line 639 of file semantics.py.

◆ data

GaudiConfig2.semantics._DictHelper.data

Definition at line 647 of file semantics.py.

◆ default

GaudiConfig2.semantics._DictHelper.default = None

Definition at line 638 of file semantics.py.

◆ is_dirty

bool GaudiConfig2.semantics._DictHelper.is_dirty = False

Definition at line 640 of file semantics.py.

◆ key_semantics

GaudiConfig2.semantics._DictHelper.key_semantics = key_semantics

Definition at line 636 of file semantics.py.

◆ value_semantics

GaudiConfig2.semantics._DictHelper.value_semantics = value_semantics

Definition at line 637 of file semantics.py.


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