Commit 17ae3fc3c7b4cc29fc54be9891d76147bebaa8bb

Authored by Christian Herdtweck
Committed by Philippe Lagadec
1 parent f7b5b5f1

ooxml: Add rough structure and idea for resetable zip stream

Showing 1 changed file with 21 additions and 0 deletions
oletools/ooxml.py
@@ -124,6 +124,27 @@ def is_ooxml(filename): @@ -124,6 +124,27 @@ def is_ooxml(filename):
124 return False 124 return False
125 125
126 126
  127 +class ZipFileResetable(io.BufferedIOBase):
  128 + """ A file-like object like zip.open returns them, only can seek() to 0
  129 +
  130 + ZipFile.open() gives file handles that can be read but not seek()ed since
  131 + the file is being decompressed in the background. This class implements a
  132 + reset() function which corresponds to a seek to 0 (which just closes the
  133 + stream and re-opens it behind the scenes
  134 + """
  135 +
  136 + def __init__(self, container, filename, mode=None):
  137 + self.container = container
  138 + self.name = filename
  139 + self.handle = container.open(filename, mode)
  140 +
  141 + def read(self, size=None):
  142 + pass
  143 +
  144 + def seek(self, pos, offset):
  145 + pass
  146 +
  147 +
127 class XmlParser(object): 148 class XmlParser(object):
128 """ parser for OOXML files """ 149 """ parser for OOXML files """
129 150