def descr_from_dtype(dtype_):
    """Get a description instance and byteorder from a (nested) NumPy dtype."""

    fields = {}
    fbyteorder = '|'
    for name in dtype_.names:
        dtype, pos = dtype_.fields[name][:2]
        kind = dtype.base.kind
        byteorder = dtype.base.byteorder
        if byteorder in '><=':
            if fbyteorder not in ['|', byteorder]:
                raise NotImplementedError(
                    "structured arrays with mixed byteorders "
                    "are not supported yet, sorry")
            fbyteorder = byteorder
        # Non-nested column
        if kind in 'biufSUc':
            col = Col.from_dtype(dtype, pos=pos)
        # Nested column
        elif kind == 'V' and dtype.shape in [(), (1,)]:
            if dtype.shape != ():
                warnings.warn(
                    "nested descriptions will be converted to scalar")
            col, _ = descr_from_dtype(dtype.base)
            col._v_pos = pos
        else:
            raise NotImplementedError(
                "structured arrays with columns with type description ``%s`` "
                "are not supported yet, sorry" % dtype)
        fields[name] = col

    return Description(fields), fbyteorder
dataset/ETHPy150Open PyTables/PyTables/tables/description.py/descr_from_dtype/original