def _read_structdesc(f):
    '''Function to read in a structure descriptor'''

    structdesc = {}

    structstart = _read_long(f)
    if structstart != 9:
        raise Exception("STRUCTSTART should be 9")

    structdesc['name'] = _read_string(f)
    predef = _read_long(f)
    structdesc['ntags'] = _read_long(f)
    structdesc['nbytes'] = _read_long(f)

    structdesc['predef'] = predef & 1
    structdesc['inherits'] = predef & 2
    structdesc['is_super'] = predef & 4

    if not structdesc['predef']:

        structdesc['tagtable'] = []
        for t in range(structdesc['ntags']):
            structdesc['tagtable'].append(_read_tagdesc(f))

        for tag in structdesc['tagtable']:
            tag['name'] = _read_string(f)

        structdesc['arrtable'] = {}
        for tag in structdesc['tagtable']:
            if tag['array']:
                structdesc['arrtable'][tag['name']] = _read_arraydesc(f)

        structdesc['structtable'] = {}
        for tag in structdesc['tagtable']:
            if tag['structure']:
                structdesc['structtable'][tag['name']] = _read_structdesc(f)

        if structdesc['inherits'] or structdesc['is_super']:
            structdesc['classname'] = _read_string(f)
            structdesc['nsupclasses'] = _read_long(f)
            structdesc['supclassnames'] = []
            for s in range(structdesc['nsupclasses']):
                structdesc['supclassnames'].append(_read_string(f))
            structdesc['supclasstable'] = []
            for s in range(structdesc['nsupclasses']):
                structdesc['supclasstable'].append(_read_structdesc(f))

        STRUCT_DICT[structdesc['name']] = structdesc

    else:

        if not STRUCT_DICT in structdesc['name']:
            raise Exception("PREDEF=1 but can't find definition")

        structdesc = STRUCT_DICT[structdesc['name']]

    return structdesc
dataset/ETHPy150Open scipy/scipy/scipy/io/idl.py/_read_structdesc/swapped operands of `in`