

def __getslice__(self, start, end):
    '\n        TODO: there are some pretty bad inefficiencies here, i believe\n        '
    ret = []
    current_run_start_offset = 0
    have_found_start = False
    g_logger.debug('NonResidentAttributeData: getslice: start: %s end: %s', hex(start), hex(end))
    if (end == sys.maxint):
        end = len(self)
    if (end < 0):
        end = (len(self) + end)
    if (start < 0):
        start = (len(self) + start)
    if (max(start, end) > len(self)):
        raise IndexError(('(%d, %d) is greater than the non resident attribute data length %s' % (start, end, len(self))))
    for (cluster_offset, num_clusters) in self._runentries:
        g_logger.debug('NonResidentAttributeData: getslice: runentry: start: %s len: %s', hex((cluster_offset * self._clusters.get_cluster_size())), hex((num_clusters * self._clusters.get_cluster_size())))
        run_length = (num_clusters * self._clusters.get_cluster_size())
        if (not have_found_start):
            if (current_run_start_offset <= start < (current_run_start_offset + run_length)):
                if (end <= (current_run_start_offset + run_length)):
                    i = (start - cluster_offset)
                    j = (end - current_run_start_offset)
                    cluster = self._clusters[cluster_offset:(cluster_offset + num_clusters)]
                    return cluster[i:j]
                else:
                    i = (start - current_run_start_offset)
                    cluster = self._clusters[cluster_offset]
                    ret.append(cluster[i:])
        elif (current_run_start_offset <= end < (current_run_start_offset + run_length)):
            j = (end - current_run_start_offset)
            cluster = self._clusters[cluster_offset:(cluster_offset + num_clusters)]
            ret.append(cluster[:j])
            return ''.join(ret)
        else:
            cluster = self._clusters[cluster_offset]
            ret.append(cluster)
        current_run_start_offset += run_length
    return ''.join(ret)

dataset/ETHPy150Open williballenthin/python-ntfs/ntfs/filesystem/__init__.py NonResidentAttributeData.__getslice__/VarMisuse@249/441 `current_run_start_offset`->`cluster_offset`