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: Write given sector to file on disk.
  
  :param sect: int, sector index
  :param data: bytes, sector data
  :param padding: single byte, padding character if data < sector size
docstr_tok: ["Write","given","sector","to","file","on","disk",".",":","param","sect",":","int",",","sector","index",":","param","data",":","bytes",",","sector","data",":","param","padding",":","single","byte",",","padding","character","if","data","<","sector","size"]
code: def write_sect(self, sect, data, padding=b"\x00"):
      """
      Write given sector to file on disk.
  
      :param sect: int, sector index
      :param data: bytes, sector data
      :param padding: single byte, padding character if data < sector size
      """
      if not isinstance(data, bytes):
          raise TypeError("write_sect: data must be a bytes string")
      if not isinstance(padding, bytes) or len(padding) != 1:
          raise TypeError(
              "write_sect: padding must be a bytes string of 1 char"
          )
      # TODO: we could allow padding=None for no padding at all
      try:
          self.fp.seek(self.sectorsize * (sect + 1))
      except:
          log.debug(
              "write_sect(): sect=%X, seek=%d, filesize=%d"
              % (sect, self.sectorsize * (sect + 1), self._filesize)
          )
          self._raise_defect(
              DEFECT_FATAL, "OLE sector index out of range"
          )
      if len(data) < self.sectorsize:
          # add padding
          data += padding * (self.sectorsize - len(data))
      elif len(data) < self.sectorsize:
          raise ValueError("Data is larger than sector size")
      self.fp.write(data)
  
imports: from __future__ import print_function
  import io
  import sys
  import struct, array, os.path, datetime, logging
label_desc: Use image node_id 16 for calling the OleFileIO obj's underlying member method code with example usage: obj.write_sect(sect, data, padding) without return types