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
def liststreams(paths): from office.OleFileIO_PL import OleFileIO result = {} 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 streams = ['/'.join(x) for x in ole.listdir()] for x in streams: if x not in result: result[x] = 0 result[x] += 1 continue
def liststreams(paths): from office.OleFileIO_PL import OleFileIO result = {} 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 streams = ['/'.join(x) for x in ole.listdir()] for x in streams: if x not in result: result[x] = 0 result[x] += 1 continue
def liststreams(paths): from office.OleFileIO_PL import OleFileIO result = {} 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 streams = ['/'.join(x) for x in ole.listdir()] for x in streams: if x not in result: result[x] = 0 result[x] += 1 continue result = result.items() result.sort(lambda a, b: cmp(a[1], b[1])) print('\n'.join('%d : %s' % (v, repr(k)) for k, v in result))