def expand_record(record, parent=None): ret = {} for key, value in record.items(): if parent: full_key = parent + "." + key else: full_key = key if type(value) == dict: expanded = expand_record(value, full_key) ret.update(expanded) else: ret[full_key] = value return ret
def __getitem__(self, index): def expand_record(record, parent=None): ret = {} for key, value in record.items(): if parent: full_key = parent + "." + key else: full_key = key if type(value) == dict: expanded = expand_record(value, full_key) ret.update(expanded) else: ret[full_key] = value return ret record = self.resultset.__getitem__(index) if not self.expand: return record else: return expand_record(record)