makes a dictionary of object-lists
    each item in the dictionary points to a list of tuples
    the tuple is (objectname,  fieldindex)
770262
def getobjectref(blocklst, commdct):
    
    objlst_dct = {}
    for eli in commdct:
        for elj in eli:
            if 'object-list' in elj:
                objlist = elj['object-list'][0]
                objlst_dct[objlist] = []

    for objlist in list(objlst_dct.keys()):
        for i in range(len(commdct)):
            for j in range(len(commdct[i])):
                if 'reference' in commdct[i][j]:
                    for ref in commdct[i][j]['reference']:
                        if ref == objlist:
                            objlst_dct[objlist].append((blocklst[i][0], j))
    return objlst_dct
1303869
def dict2obj(d):
    
    if isinstance(d, (list, tuple)):
        d = [dict2obj(x) for x in d]
    if not isinstance(d, dict):
        return d
    class ObjectFromDict(object):
        pass
    o = ObjectFromDict() #an object created from a dict
    for k in d:
        o.__dict__[k] = dict2obj(d[k])
    return o
1312584
def toDict(self):
        
        d = {}
        nindices = self.getNumIndices()
        for i in range(self.getNumRows()):
            row = list(self.getRowByIndex(i))
            if nindices > 1:
                key = tuple(row[:nindices])
            elif nindices == 1:
                key = row[0]
            else:
                key = None
            if len(row) - nindices == 0:
                d[key] = None
            elif len(row) - nindices == 1:
                d[key] = row[nindices]
            else:
                d[key] = tuple(row[nindices:])
        return d
532020
def object_to_dict(cls, obj):
        
        dict_obj = dict()
        if obj is not None:
            if type(obj) == list:
                dict_list = []
                for inst in obj:
                    dict_list.append(cls.object_to_dict(inst))
                dict_obj["list"] = dict_list

            elif not cls.is_primitive(obj):
                for key in obj.__dict__:
                    # is an object
                    if type(obj.__dict__[key]) == list:
                        dict_list = []
                        for inst in obj.__dict__[key]:
                            dict_list.append(cls.object_to_dict(inst))
                        dict_obj[key] = dict_list
                    elif not cls.is_primitive(obj.__dict__[key]):
                        temp_dict = cls.object_to_dict(obj.__dict__[key])
                        dict_obj[key] = temp_dict
                    else:
                        dict_obj[key] = obj.__dict__[key]
            elif cls.is_primitive(obj):
                return obj
        return dict_obj
534063
def fieldnames(self):
        ''' 
        '''
        if not self._fields:
            if self._item_class is not None:
                for m in inspect.getmembers(self._item_class):
                    if m[0] == 'fields' and isinstance(m[1], dict):
                        self._fields = m[1]
                if not self._fields:
                    raise RuntimeError('Unknown item type, no fields: %s' % self._item_class)
            else:
                raise RuntimeError('Item class is not defined, %s' % self._item_class)
        return self._fields.keys()
1070425
def tlist2dict(tuple_list,**kwargs):
    '''
        
    '''
    if('deepcopy' in kwargs):
        deepcopy = kwargs['deepcopy']
    else:
        deepcopy = 1
    if('check' in kwargs):
        check = kwargs['check']
    else:
        check = 1
    if(check):
        if(tltl.is_tlist(tuple_list)):
            pass
        else:
            return(None)
    else:
        pass
    j = {}
    if(deepcopy):
        new = copy.deepcopy(tuple_list)
    else:
        new = tuple_list
    for i in range(0,new.__len__()):
        temp = new[i]
        key = temp[0]
        value = temp[1]
        j[key] = value
    return(j)
665561
def _build_indexes(self):
        
        if isinstance(self._data, list):
            for d in self._data:
                if not isinstance(d, dict):
                    err = u'Cannot build index for non Dict type.'
                    self._tcex.log.error(err)
                    raise RuntimeError(err)

                data_obj = DataObj(d)
                self._master_index.setdefault(id(data_obj), data_obj)

                for key, value in d.items():
                    # bcs - update this
                    # if not isinstance(value, (types.StringType, float, int)):
                    # TODO: This is not Python 3 ready
                    if not isinstance(value, (float, int, str)):
                        # For comparison operators the value needs to be a StringType
                        self._tcex.log.debug(u'Can only build index String Types.')
                        continue

                    self._indexes.setdefault(key, {}).setdefault(value, []).append(data_obj)
        else:
            err = u'Only *List* data type is currently supported'
            self._tcex.log.error(err)
            raise RuntimeError(err)
85210
def _as_list(obj):
    """"""
    if obj is None:
        return None
    elif isinstance(obj, string_types):
        return [obj]
    elif isinstance(obj, tuple):
        return list(obj)
    elif not hasattr(obj, '__len__'):
        return [obj]
    else:
        return obj
1295426
def p_object_ty(self, p):
        
        field_types = {} if len(p) == 5 else p[5]
        p[0] = Object(p[3], **field_types)
504378
def tolist(self):
        
        return [[x.val for x in theclass.items] for theclass in self.classes]
1121933
def list_indexes(cls):
        

        cls_list = cls.list_mapped_classes()
        rtn_obj = {}
        for key, value in cls_list.items():
            idx = value.es_defs.get('kds_esIndex')[0]
            try:
                rtn_obj[idx].append(value)
            except KeyError:
                rtn_obj[idx] = [value]
        return rtn_obj
957564
def indexables(self):
        
        if self._indexables is None:

            self._indexables = []

            # index columns
            self._indexables.extend([
                IndexCol(name=name, axis=axis, pos=i)
                for i, (axis, name) in enumerate(self.attrs.index_cols)
            ])

            # values columns
            dc = set(self.data_columns)
            base_pos = len(self._indexables)

            def f(i, c):
                klass = DataCol
                if c in dc:
                    klass = DataIndexableCol
                return klass.create_for_block(i=i, name=c, pos=base_pos + i,
                                              version=self.version)

            self._indexables.extend(
                [f(i, c) for i, c in enumerate(self.attrs.values_cols)])

        return self._indexables
523939
def list_object_names(self, marker=None, limit=None, prefix=None,
            delimiter=None, end_marker=None, full_listing=False):
        
        if full_listing:
            objects = self.list_all(prefix=prefix)
        else:
            objects = self.list(marker=marker, limit=limit, prefix=prefix,
                    delimiter=delimiter, end_marker=end_marker)
        return [obj.name for obj in objects]
563175
def itertuples(self, index=True, name='Raccoon'):
        
        fields = [self._index_name] if index else list()
        fields.extend(self._columns)
        row_tuple = namedtuple(name, fields)
        for i in range(len(self._index)):
            row = {self._index_name: self._index[i]} if index else dict()
            for c, col in enumerate(self._columns):
                row[col] = self._data[c][i]
            yield row_tuple(**row)
1191061
def extractfields(data, commdct, objkey, fieldlists):
    """"""
    # TODO : this assumes that the field list identical for
    # each instance of the object. This is not true.
    # So we should have a field list for each instance of the object
    # and map them with a zip
    objindex = data.dtls.index(objkey)
    objcomm = commdct[objindex]
    objfields = []
    # get the field names of that object
    for dct in objcomm[0:]:
        try:
            thefieldcomms = dct['field']
            objfields.append(thefieldcomms[0])
        except KeyError as err:
            objfields.append(None)
    fieldindexes = []
    for fieldlist in fieldlists:
        fieldindex = []
        for item in fieldlist:
            if isinstance(item, int):
                fieldindex.append(item)
            else:
                fieldindex.append(objfields.index(item) + 0)
                # the index starts at 1, not at 0
        fieldindexes.append(fieldindex)
    theobjects = data.dt[objkey]
    fieldcontents = []
    for theobject, fieldindex in zip(theobjects, fieldindexes):
        innerlst = []
        for item in fieldindex:
            try:
                innerlst.append(theobject[item])
            except IndexError as err:
                break
        fieldcontents.append(innerlst)
        # fieldcontents.append([theobject[item] for item in fieldindex])
    return fieldcontents
1116736
def p_objects_list(self, p):
        ''''''
        if len(p) == 3:
            p[1].append(p[2])
            p[0] = p[1]
        elif len(p) == 2:
            p[0] = [p[1]]
573555
def make_iterable(obj):
    
    if not obj:
        return tuple()

    if isinstance(obj, (list, tuple, set)):
        return obj

    return (obj,)