Retrieve the highest-indexed file that starts at or before byte_index.
190251
def get_rightmost_index(byte_index=0, file_starts=[0]):

    '''
    
    '''
    i = 1
    while i <= len(file_starts):
        start = file_starts[-i]
        if start <= byte_index:
            return len(file_starts) - i
        else:
            i += 1
    else:
        raise Exception('byte_index lower than all file_starts')
574787
int getShort(final long off) throws IOException, InterruptedException {
        if (off < 0 || off > zipFileSlice.len - 2) {
            throw new IndexOutOfBoundsException();
        }
        if (read(off, scratch, 0, 2) < 2) {
            throw new EOFException("Unexpected EOF");
        }
        return ((scratch[1] & 0xff) << 8) | (scratch[0] & 0xff);
    }
476287
@Override
    public V getBest(ByteBuffer b, int offset, int len) {
        if (b.hasArray())
            return getBest(0, b.array(), b.arrayOffset() + b.position() + offset, len);
        return getBest(0, b, offset, len);
    }
552882
def extract_file_from_zip(bytes_io, expected_file):
    """"""
    zipf = zipfile.ZipFile(bytes_io) 
    return zipf.read(expected_file)
1127265
def StartFileFetch(self, pathspec, request_data=None):
    """"""
    # Create an index so we can find this pathspec later.
    self.state.indexed_pathspecs.append(pathspec)
    self.state.request_data_list.append(request_data)
    self._TryToStartNextPathspec()
263763
def _get_by_index(self, index):
        """"""
        volume_or_disk = self.parser.get_by_index(index)
        volume, disk = (volume_or_disk, None) if not isinstance(volume_or_disk, Disk) else (None, volume_or_disk)
        return volume, disk
540539
private byte getByte(int index) {
        if (index < initialSize) {
            return pool.get(0)[index];
        }
        
        index -= initialSize;
        return pool.get(index / incrementalSize + 1)[index % incrementalSize];
    }
742279
def GetLoadingOrder(self):
    """"""
    result = {}
    for filename, mapping in self._file_mapping.iteritems():
      loading_order = mapping['loading_order']
      if loading_order is not None:
        result[loading_order] = filename
    return list(result[key] for key in sorted(result))
1211889
def __read(self, i: int) -> bytes:
        """"""
        b = self.data[self.idx: self.idx + i]
        self.idx += i
        if len(b) != i:
            raise bencodepy.DecodingError(
                "Incorrect byte length returned between indexes of {0} and {1}. Possible unexpected End of File."
                    .format(str(self.idx), str(self.idx - i)))
        return b
466037
def write_index(self):
        """"""
        self.fileobj.seek(self.last_offset)
        index = index_header.build(dict(entries=self.entries))
        self.fileobj.write(index)
        self.filesize = self.fileobj.tell()
990462
private V getBest(int t, byte[] b, int offset, int len) {
        for (int i = 0; i < len; i++) {
            byte c = b[offset + i];
            int index = __lookup[c & 0x7f];
            if (index >= 0) {
                int idx = t * ROW_SIZE + index;
                int nt = _rowIndex[idx];
                if (nt == 0)
                    break;
                t = nt;
            } else {
                char[] big = _bigIndex == null ? null : _bigIndex[t];
                if (big == null)
                    return null;
                int nt = big[c];
                if (nt == 0)
                    break;
                t = nt;
            }

            // Is the next Trie is a match
            if (_key[t] != null) {
                // Recurse so we can remember this possibility
                V best = getBest(t, b, offset + i + 1, len - i - 1);
                if (best != null)
                    return best;
                break;
            }
        }
        return (V) _value[t];
    }
1080260
private static int getIndexFromFilename(String fileName) {
        // remove the beginning of the file name
        String resStr = fileName.replace(
                latestMOTDSerializedFileName.substring(0, latestMOTDSerializedFileName.indexOf("{index}")), "");

        // remove the end of the file name
        resStr = resStr.replace(
                latestMOTDSerializedFileName.substring(latestMOTDSerializedFileName.indexOf("{index}") + 7), "");

        return Integer.parseInt(resStr);
    }
354556
def get_index_from_filename(self, filename):
        
        filenames = [d.filename for d in self.data]
        return filenames.index(filename)
1310331
def get_overlay_data_start_offset(self):
        """"""

        largest_offset_and_size = (0, 0)

        def update_if_sum_is_larger_and_within_file(offset_and_size, file_size=len(self.__data__)):
            if sum(offset_and_size) <= file_size and sum(offset_and_size) > sum(largest_offset_and_size):
                return offset_and_size
            return largest_offset_and_size

        if hasattr(self, 'OPTIONAL_HEADER'):
            largest_offset_and_size = update_if_sum_is_larger_and_within_file(
                (self.OPTIONAL_HEADER.get_file_offset(), self.FILE_HEADER.SizeOfOptionalHeader))

        for section in self.sections:
            largest_offset_and_size = update_if_sum_is_larger_and_within_file(
                (section.PointerToRawData, section.SizeOfRawData))

        skip_directories = [DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_SECURITY']]

        for idx, directory in enumerate(self.OPTIONAL_HEADER.DATA_DIRECTORY):
            if idx in skip_directories:
                continue
            try:
                largest_offset_and_size = update_if_sum_is_larger_and_within_file(
                    (self.get_offset_from_rva(directory.VirtualAddress), directory.Size))
            # Ignore directories with RVA out of file
            except PEFormatError:
                continue

        if len(self.__data__) > sum(largest_offset_and_size):
            return sum(largest_offset_and_size)

        return None
1323422
def getbyteslice(self, start, end):
        """"""
        c = self._rawarray[start:end]
        return c
140386
private void getNextFileToRead() throws IOException {
    if (this.currentFile != null && this.currentFileItr != null) {
      closeCurrentFile();
      incrementBytesReadCounter();
    }

    while (!this.hasNext && !this.filesToPull.isEmpty()) {
      this.currentFile = this.filesToPull.remove(0);
      this.currentFileItr = downloadFile(this.currentFile);
      this.hasNext = this.currentFileItr == null ? false : this.currentFileItr.hasNext();
      LOG.info("Will start downloading file: " + this.currentFile);
    }
  }
591627
private int parseFileIndex(String fileName) {
    Matcher match = null;
    String indexString = null;
    try {
      match = exportPattern.matcher(fileName);
      match.find();
      indexString = match.group(1);
    } catch (Exception e) {
      throw new IllegalStateException(String.format("Failed to parse file '%s'", fileName), e);
    }
    long longValue = Long.parseLong(indexString);
    if (longValue > Integer.MAX_VALUE) {
      throw new IndexOutOfBoundsException(String.format(
          "Invalid fileName '%s'; max allowable index is %d, got %d instead",
          fileName, Integer.MAX_VALUE, longValue));
    }
    return (int) longValue;
  }