def ensure_dict_from_str(s, **kwargs):
    'Given a multiline string with key=value items convert it to a dictionary\n\n    Parameters\n    ----------\n    s: str or dict\n\n    Returns None if input s is empty\n    '
    if (not s):
        return None
    if isinstance(s, dict):
        return s
    out = {}
    for value_str in ensure_list_from_str(s, **kwargs):
        if ('=' not in value_str):
            raise ValueError('{} is not in key=value format'.format(repr(value_str)))
        (k, v) = value_str.split('=', 1)
        if (k in out):
            err = 'key {} was already defined in {}, but new value {} was provided'.format(k, out, v)
            raise ValueError(err)
        out[k] = v
    return out
Given a multiline string with key=value items convert it to a dictionary

Parameters
----------
s: str or dict

Returns None if input s is empty
def ensure_dict_from_str(s, **kwargs):
    'Given a multiline string with key=value items convert it to a dictionary\n\n    Parameters\n    ----------\n    s: str or dict\n\n    Returns None if input s is empty\n    '
    if (not s):
        return None
    if isinstance(s, dict):
        return s
    out = {}
    for value_str in ensure_list_from_str(s, **kwargs):
        if ('=' not in value_str):
            raise ValueError('{} is not in key=value format'.format(repr(value_str)))
        (k, v) = value_str.split('=', 1)
        if (k in out):
            err = 'key {} was already defined in {}, but new value {} was provided'.format(k, out, v)
            raise ValueError(err)
        out[k] = v
    return out