Convert a value to a basic dict format
    :param val: The value
    :param onts: Schemas to be used in the conversion
    :return: The basic dictionary
330294
def _eval(val, onts, mdb_safe):
    
    if isinstance(val, six.string_types):
        val = val.strip()
        if not val:
            return None
        else:
            return val
    elif isinstance(val, dict) or isinstance(val, SamlBase):
        return to_dict(val, onts, mdb_safe)
    elif isinstance(val, list):
        lv = []
        for v in val:
            if isinstance(v, dict) or isinstance(v, SamlBase):
                lv.append(to_dict(v, onts, mdb_safe))
            else:
                lv.append(v)
        return lv
    return val
326366
def to_python(self, value):
        
        if self.blank and not value:
            return {}
        value = value or '{}'
        if isinstance(value, six.binary_type):
            value = six.text_type(value, 'utf-8')
        if isinstance(value, six.string_types):
            try:
                # with django 1.6 i have '"{}"' as default value here
                if value[0] == value[-1] == '"':
                    value = value[1:-1]

                return json.loads(value)
            except Exception as err:
                raise ValidationError(str(err))
        else:
            return value
380044
def convertDict2Attrs(self, *args, **kwargs):
        
        constantFields = ['id', 'groupName', 'name', 'homePhone', 'mobilePhone1', 'phoneNumber', 'postcode', 'emailAddress']
        def convierte(data):
            """Recursively convert the fields on the data given to a python object."""
            # Iterators, lists and dictionaries
            # Here comes the recursive calls!
            try:
                it = iter(data)
                if type(it) == type(iter({})):
                    d = {}
                    for k in it:
                        if k in constantFields:
                            d[k] = data[k]
                        else:
                            d[k] = convierte(data[k])
                    data = d
                if type(it) == type(iter([])):
                    l = []
                    for e in it:
                        l.append(convierte(e))
                    data = l
            except TypeError as terr:
                pass
            except Exception as ex:
                raise ex

            # Python built-in types: ints, floats, or even datetimes. If it
            # cannot convert it to a built-in type, leave it as string, or
            # as-is. There may be nested Mambu objects here!
            # This are the recursion base cases!
            try:
                d = int(data)
                if str(d) != data: # if string has trailing 0's, leave it as string, to not lose them
                    return data
                return d
            except (TypeError, ValueError) as tverr:
                try:
                    return float(data)
                except (TypeError, ValueError) as tverr:
                    try:
                        return self.util_dateFormat(data)
                    except (TypeError, ValueError) as tverr:
                        return data

            return data

        self.attrs = convierte(self.attrs)
1260319
def deep_convert_dict(value):
    
    to_ret = value
    if isinstance(value, OrderedDict):
        to_ret = dict(value)

    try:
        for k, v in to_ret.items():
            to_ret[k] = deep_convert_dict(v)
    except AttributeError:
        pass

    return to_ret
1158394
def _convert(self, val):
        
        if isinstance(val, dict) and not isinstance(val, DotDict):
            return DotDict(val), True
        elif isinstance(val, list) and not isinstance(val, DotList):
            return DotList(val), True

        return val, False
1232437
def to_json(value, **kwargs):
        
        serial_dict = {
            key: (
                val.serialize(**kwargs) if isinstance(val, HasProperties)
                else val
            )
            for key, val in iteritems(value)
        }
        return serial_dict
572486
def convert_dict_to_option_dict(input_dict):
    """"""
    ret_dict = {}
    for key, value in input_dict.items():
        ret_dict[key] = convert_value_to_option_tuple(value)
    return ret_dict
1041777
def to_val(teleport_schema):
    """"""
    translated = _translate(teleport_schema)
    if isinstance(translated, BaseSchema):
        return translated

    return Schema(translated)
255804
def fmt_dict_vals(dict_vals, shorten=True):
    
    items = dict_vals.items()
    if not items:
        return [fmt_val(None, shorten=shorten)]
    return ["%s=%s" % (k, fmt_val(v, shorten=shorten)) for k,v in items]
839702
def _parse_phone(self, val):
        

        ret = {
            'type': None,
            'value': None
        }

        try:

            ret['type'] = val[1]['type']

        except (IndexError, KeyError, ValueError, TypeError):

                pass

        ret['value'] = val[3].strip()

        try:

            self.vars['phone'].append(ret)

        except AttributeError:

            self.vars['phone'] = []
            self.vars['phone'].append(ret)
339773
def to_model(cls, value):
    

    if isinstance(value, cls) or value is None:
        pass  # skip if right type or value is None

    elif issubclass(cls, Enum):
        value = cls(value)

    elif is_model(cls) and isinstance(value, dict):
        value = convert_key_to_attr_names(cls, value)
        value = cls(**value)

    else:
        value = cls(value)

    return value
570458
def data_to_dict(self, sysbase=False):
        
        assert isinstance(sysbase, bool)

        ret = {}

        for key in self.data_keys:
            if (not sysbase) and (key in self._store):
                val = self._store[key]
            else:
                val = self.__dict__[key]

            ret[key] = val

        return ret
1068460
def to_dict(self):
        ""
        ndict = {}
        for key, val in self.__dict__.items():
            if key[0] == "_":
                ndict[key[1:]] = val
            else:
                ndict[key] = val
        return ndict
506021
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]:
    
    attrs = dict(attrs)
    for k, v in attrs.items():
        if isinstance(v, np.ndarray):
            attrs[k] = v.tolist()
        elif isinstance(v, np.generic):
            attrs[k] = v.item()
    return attrs
430365
def convert_kv_to_dict(data):
    
    output = {}
    for line in data.split("\n"):
        stripped = line.strip()
        if stripped:
            key, value = stripped.split("=", 1)
            output[key] = value
    return output
120840
def convert(self, obj):
        
        if self.pristine_if_invalid:
            raise NotImplementedError('pristine_if_invalid option is not supported yet')

        nex = get_nexml_el(obj)
        assert nex
        self._recursive_convert_dict(nex)
        # pluralization simplifications in hbf:
        # convert dicts to lists for the primary datastructures...
        self._dict_to_list_of_dicts(nex, 'otus')
        self._dict_to_list_of_dicts(nex, 'otus', 'otu')
        self._dict_to_list_of_dicts(nex, 'trees')
        self._dict_to_list_of_dicts(nex, 'trees', 'tree')
        self._dict_to_list_of_dicts(nex, 'trees', 'tree', 'node')
        self._dict_to_list_of_dicts(nex, 'trees', 'tree', 'edge')
        if self._add_tree_xsi_type:
            for tb in nex.get('trees', []):
                for t in tb.get('tree', []):
                    t.setdefault('@xsi:type', 'nex:FloatTree')
        nex['@nexml2json'] = str(DIRECT_HONEY_BADGERFISH)
        return obj
694721
def flatten_dict_vals(dict_):
    
    if isinstance(dict_, dict):
        return dict([
            ((key, augkey), augval)
            for key, val in dict_.items()
            for augkey, augval in flatten_dict_vals(val).items()
        ])
    else:
        return {None: dict_}