class_docstr: OLE container object
  
  This class encapsulates the interface to an OLE 2 structured
  storage file.  Use the listdir and openstream methods to
  access the contents of this file.
  
  Object names are given as a list of strings, one for each subentry
  level.  The root entry should be omitted.  For example, the following
  code extracts all image streams from a Microsoft Image Composer file::
  
      ole = OleFileIO("fan.mic")
  
      for entry in ole.listdir():
          if entry[1:2] == "Image":
              fin = ole.openstream(entry)
              fout = open(entry[0:1], "wb")
              while True:
                  s = fin.read(8192)
                  if not s:
                      break
                  fout.write(s)
  
  You can use the viewer application provided with the Python Imaging
  Library to view the resulting files (which happens to be standard
  TIFF files).
class_docstr_tok: ["OLE","container","object","This","class","encapsulates","the","interface","to","an","OLE","2","structured","storage","file",".","Use","the","listdir","and","openstream","methods","to","access","the","contents","of","this","file",".","Object","names","are","given","as","a","list","of","strings",",","one","for","each","subentry","level",".","The","root","entry","should","be","omitted",".","For","example",",","the","following","code","extracts","all","image","streams","from","a","Microsoft","Image","Composer","file",":",":","ole","=","OleFileIO","(","``","fan.mic","''",")","for","entry","in","ole.listdir","(",")",":","if","entry","[","1:2","]","==","``","Image","''",":","fin","=","ole.openstream","(","entry",")","fout","=","open","(","entry","[","0:1","]",",","``","wb","''",")","while","True",":","s","=","fin.read","(","8192",")","if","not","s",":","break","fout.write","(","s",")","You","can","use","the","viewer","application","provided","with","the","Python","Imaging","Library","to","view","the","resulting","files","(","which","happens","to","be","standard","TIFF","files",")","."]
docstr: Read given sector from file on disk.
  
  :param sect: int, sector index
  :returns: a string containing the sector data.
docstr_tok: ["Read","given","sector","from","file","on","disk",".",":","param","sect",":","int",",","sector","index",":","returns",":","a","string","containing","the","sector","data","."]
code: def getsect(self, sect):
      """
      Read given sector from file on disk.
  
      :param sect: int, sector index
      :returns: a string containing the sector data.
      """
      # From [MS-CFB]: A sector number can be converted into a byte offset
      # into the file by using the following formula:
      # (sector number + 1) x Sector Size.
      # This implies that sector #0 of the file begins at byte offset Sector
      # Size, not at 0.
  
      # [PL] the original code in PIL was wrong when sectors are 4KB instead of
      # 512 bytes:
      # self.fp.seek(512 + self.sectorsize * sect)
      # [PL]: added safety checks:
      # print("getsect(%X)" % sect)
      try:
          self.fp.seek(self.sectorsize * (sect + 1))
      except:
          log.debug(
              "getsect(): sect=%X, seek=%d, filesize=%d"
              % (sect, self.sectorsize * (sect + 1), self._filesize)
          )
          self._raise_defect(
              DEFECT_FATAL, "OLE sector index out of range"
          )
      sector = self.fp.read(self.sectorsize)
      if len(sector) != self.sectorsize:
          log.debug(
              "getsect(): sect=%X, read=%d, sectorsize=%d"
              % (sect, len(sector), self.sectorsize)
          )
          self._raise_defect(DEFECT_FATAL, "incomplete OLE sector")
      return sector
  
imports: from __future__ import print_function
  import io
  import sys
  import struct, array, os.path, datetime, logging
label_desc: Use image node_id 15 for calling the OleFileIO obj's underlying member method code with example usage: obj.getsect(sect) and returns: sector