def dumpstreams(stream, paths, out): from office.OleFileIO_PL import OleFileIO stream = stream.split('/') out = out if out.endswith('/') else '%s/' % out if not os.path.exists(out): raise OSError('path "%s" not found' % out) for filename in paths: if not os.path.exists(filename): log('%s : file not found', filename) continue try: ole = OleFileIO(filename) except IOError as msg: log('%s : not an ole file : %s', filename, msg) continue if stream not in ole.listdir(): # log('%s : stream "%s" not found'%(filename, repr(stream))) continue name = '%s.stream' % (os.path.basename(filename)) path = '%s%s' % (out, name) log('%s : writing stream "%s"' % (filename, path)) try: stm = ole.openstream(stream) except IOError as msg: log('%s : stream %s error : %s', filename, stream, msg) continue file(path, 'wb').write(stm.read()) return
def dumpstreams(stream, paths, out): from office.OleFileIO_PL import OleFileIO stream = stream.split('/') out = out if out.endswith('/') else '%s/'%out if not os.path.exists(out): raise OSError('path "%s" not found'% out) for filename in paths: if not os.path.exists(filename): log('%s : file not found',filename) continue try: ole = OleFileIO(filename) except IOError,msg: log('%s : not an ole file : %s',filename,msg) continue if stream not in ole.listdir(): # log('%s : stream "%s" not found'%(filename, repr(stream))) continue name = '%s.stream'%(os.path.basename(filename)) path = '%s%s'%(out,name) log('%s : writing stream "%s"'%(filename, path)) try: stm = ole.openstream(stream) except IOError, msg: log('%s : stream %s error : %s', filename,stream,msg) continue