def _xfs_inventory_output(out):
    data = []
    out = [line for line in out.split("\n") if line.strip()]

    # No inventory yet
    if len(out) == 1 and 'restore status' in out[0].lower():
        return {'restore_status': out[0]}

    ident = 0
    data.append("{")
    for line in out[:-1]:
        if len([elm for elm in line.strip().split(":") if elm]) == 1:
            n_ident = len(re.sub("[^\t]", "", line))
            if ident > n_ident:
                for step in range(ident):
                    data.append("},")
            ident = n_ident
            data.append(_xr_to_keyset(line))
            data.append("{")
        else:
            data.append(_xr_to_keyset(line))
    for step in range(ident + 1):
        data.append("},")
    data.append("},")

    # We are evaling into a python dict, a json load
    # would be safer
    data = eval('\n'.join(data))[0]  # pylint: disable=W0123
    data['restore_status'] = out[-1]

    return data
Transform xfsrestore inventory data output to a Python dict source and evaluate it.
dataset/ETHPy150Open saltstack/salt/salt/modules/xfs.py/_xfs_inventory_output