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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 599 of file semantics.py.

599 def __init__(self, key_semantics, value_semantics):
600 self.key_semantics = key_semantics
601 self.value_semantics = value_semantics
602 self.default = None
603 self._data = {}
604 self.is_dirty = False
605

Member Function Documentation

◆ __contains__()

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

Definition at line 644 of file semantics.py.

644 def __contains__(self, key):
645 return self.key_semantics.store(key) in self.data
646

◆ __delitem__()

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

Definition at line 624 of file semantics.py.

624 def __delitem__(self, key):
625 if not self.is_dirty:
626 raise RuntimeError("cannot remove elements from the default value")
627 self.data.__delitem__(self.key_semantics.store(key))
628

◆ __getitem__()

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

Definition at line 613 of file semantics.py.

613 def __getitem__(self, key):
614 return self.value_semantics.load(
615 self.data.__getitem__(self.key_semantics.store(key))
616 )
617

◆ __iter__()

GaudiConfig2.semantics._DictHelper.__iter__ ( self)

Definition at line 629 of file semantics.py.

629 def __iter__(self):
630 for key in self.data:
631 yield self.key_semantics.load(key)
632

◆ __len__()

GaudiConfig2.semantics._DictHelper.__len__ ( self)

Definition at line 610 of file semantics.py.

610 def __len__(self):
611 return len(self.data)
612

◆ __repr__()

GaudiConfig2.semantics._DictHelper.__repr__ ( self)

Definition at line 667 of file semantics.py.

667 def __repr__(self):
668 return repr(self.data)
669
670

◆ __setitem__()

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

Definition at line 618 of file semantics.py.

618 def __setitem__(self, key, value):
619 self.is_dirty = True
620 self.data.__setitem__(
621 self.key_semantics.store(key), self.value_semantics.store(value)
622 )
623

◆ data()

GaudiConfig2.semantics._DictHelper.data ( self)

Definition at line 607 of file semantics.py.

607 def data(self):
608 return self._data if self.is_dirty else self.default
609

◆ get()

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

Definition at line 647 of file semantics.py.

647 def get(self, key, default=None):
648 key = self.key_semantics.store(key)
649 if key in self.data:
650 return self.value_semantics.load(self.data[key])
651 return default
652

◆ items()

GaudiConfig2.semantics._DictHelper.items ( self)

Definition at line 636 of file semantics.py.

636 def items(self):
637 for key, value in self.data.items():
638 yield (self.key_semantics.load(key), self.value_semantics.load(value))
639

◆ keys()

GaudiConfig2.semantics._DictHelper.keys ( self)

Definition at line 633 of file semantics.py.

633 def keys(self):
634 return list(self)
635

◆ opt_value()

GaudiConfig2.semantics._DictHelper.opt_value ( self)

Definition at line 661 of file semantics.py.

661 def opt_value(self):
662 return {
663 self.key_semantics.opt_value(key): self.value_semantics.opt_value(value)
664 for key, value in self.data.items()
665 }
666

◆ update()

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

Definition at line 656 of file semantics.py.

656 def update(self, otherMap):
657 self.is_dirty = True
658 for key, value in otherMap.items():
659 self.data[self.key_semantics.store(key)] = self.value_semantics.store(value)
660

◆ values()

GaudiConfig2.semantics._DictHelper.values ( self)

Definition at line 640 of file semantics.py.

640 def values(self):
641 for value in self.data.values():
642 yield self.value_semantics.load(value)
643

Member Data Documentation

◆ _data

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

Definition at line 603 of file semantics.py.

◆ data

GaudiConfig2.semantics._DictHelper.data

Definition at line 611 of file semantics.py.

◆ default

GaudiConfig2.semantics._DictHelper.default = None

Definition at line 602 of file semantics.py.

◆ is_dirty

bool GaudiConfig2.semantics._DictHelper.is_dirty = False

Definition at line 604 of file semantics.py.

◆ key_semantics

GaudiConfig2.semantics._DictHelper.key_semantics = key_semantics

Definition at line 600 of file semantics.py.

◆ value_semantics

GaudiConfig2.semantics._DictHelper.value_semantics = value_semantics

Definition at line 601 of file semantics.py.


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