# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_util.ipynb.

# %% auto 0
__all__ = ['getbval', 'getmval', 'dcsrct']

# %% ../nbs/03_util.ipynb 3
from typing import Any, Optional

# %% ../nbs/03_util.ipynb 5
def getbval(bases: tuple, attr: str, default = None) -> Optional[Any]:
    '''Get the first attribute value found in the base classes'''
    for base in bases:
        if hasattr(base, attr): return getattr(base, attr)
    return default

def getmval(bases: tuple, cls_dict: dict, attr: str, default = None) -> Optional[Any]:
    '''Get the first attribute either from the `cls_dict` or in any of the base classes'''
    cval = cls_dict.get(attr)
    bval = getbval(bases, attr, default)
    return cval if cval is not None else bval

def dcsrct(d: dict, *args, __flbk: Any = None) -> tuple:
    '''Deconstruct a dictionary
    
    Examples
    --------
    >>> b, d = dcsrct(dict(a=1, b=2, c=3, d=4), 'b', 'd')
    >>> b, d
    (2, 4)
    '''
    if __flbk is None: __flbk = tuple(None for _ in range(len(args)))
    return tuple(d.get(attr, dflt) for attr, dflt in zip(args, __flbk))
