Commit d9a13e56c8348b93f15980e139c9d28af673670f

Authored by Christian Herdtweck
1 parent b3c584b2

ooxml: Mention other file-like classes in ZipSubFile

Also: 2 minor changes
Showing 1 changed file with 15 additions and 3 deletions
oletools/ooxml.py
@@ -95,11 +95,11 @@ def get_type(filename): @@ -95,11 +95,11 @@ def get_type(filename):
95 logging.debug(u' ' + debug_str(elem)) 95 logging.debug(u' ' + debug_str(elem))
96 try: 96 try:
97 is_xls |= elem.attrib['ContentType'].startswith( 97 is_xls |= elem.attrib['ContentType'].startswith(
98 - CONTENT_TYPES_EXCEL) 98 + CONTENT_TYPES_EXCEL)
99 is_doc |= elem.attrib['ContentType'].startswith( 99 is_doc |= elem.attrib['ContentType'].startswith(
100 - CONTENT_TYPES_WORD) 100 + CONTENT_TYPES_WORD)
101 is_ppt |= elem.attrib['ContentType'].startswith( 101 is_ppt |= elem.attrib['ContentType'].startswith(
102 - CONTENT_TYPES_PPT) 102 + CONTENT_TYPES_PPT)
103 except KeyError: # ContentType not an attr 103 except KeyError: # ContentType not an attr
104 pass 104 pass
105 105
@@ -153,6 +153,9 @@ class ZipSubFile(object): @@ -153,6 +153,9 @@ class ZipSubFile(object):
153 handle: direct handle to subfile stream, created by ZipFile.open() 153 handle: direct handle to subfile stream, created by ZipFile.open()
154 pos: current position within stream (can deviate from actual position in 154 pos: current position within stream (can deviate from actual position in
155 self.handle if we fake jump to end) 155 self.handle if we fake jump to end)
  156 +
  157 + See also (and maybe could some day merge with):
  158 + ppt_record_parser.IterStream; also: oleobj.FakeFile
156 """ 159 """
157 160
158 def __init__(self, container, filename, mode='r', size=None): 161 def __init__(self, container, filename, mode='r', size=None):
@@ -172,6 +175,15 @@ class ZipSubFile(object): @@ -172,6 +175,15 @@ class ZipSubFile(object):
172 self.pos = None 175 self.pos = None
173 self.closed = True 176 self.closed = True
174 177
  178 + def readable(self):
  179 + return True
  180 +
  181 + def writable(self):
  182 + return False
  183 +
  184 + def seekable(self):
  185 + return True
  186 +
175 def open(self): 187 def open(self):
176 """ open subfile for reading; open mode given to constructor before """ 188 """ open subfile for reading; open mode given to constructor before """
177 if self.handle is not None: 189 if self.handle is not None: