Ejemplo n.º 1
0
 def _isUnique(self,item,default=None,dm=None,munge=True):
     # usage:
     #    variation of _getMember which only returns True (if not present) or False (if present)
     #    and optionally updates the index
     #    if item and not present and default supplied set it
     # inputs:
     #    item      - key whose value is to be retrieved
     #    default   - value to set a new key to if supplied
     #    dm        - dictionary or mtcollection munging mode ['keys'|'items'|'values']
     #    munge     - mungeKey [True|False]
     # returns:
     #    unique    - [True|False]
     unique = False
     from metabulate.utils.utils import _mungeKey
     if munge: item = _mungeKey(item,dm=dm)
     if not item in self._items:
         if default is not None: self._setItem(item,default)
         unique = True
     return unique
Ejemplo n.º 2
0
 def _getMember(self,item,default=None,returnSet=None,dm=None,munge=True):
     # usage:
     #    gets an item from the index if present
     #    if not indexes it against its default, returning this
     #    otherwise returns None
     #    munges the index to ensure it can be hashed
     # inputs:
     #    item      - key whose value is to be retrieved
     #    default   - value to set a new key to if supplied
     #    returnSet - if None returns value if match found, else returns the default if applied
     #    dm        - dictionary or mtcollection munging mode ['keys'|'items'|'values']
     #    munge     - mungeKey [True|False]
     # returns:
     #    value for key if present, default if supplied and key not present, else None
     from metabulate.utils.utils import _mungeKey
     if munge: item = _mungeKey(item,dm)
     if item in self._items: return self._getItem(item,'')
     else:
         if default is not None:
             self._setItem(item,default)
             if returnSet is None: return None
             else: return default
Ejemplo n.º 3
0
 def _setMember(self,item,value):
     from metabulate.utils.utils import _mungeKey
     return self._setItem(_mungeKey(item),value)