def test_unpack(self): if self.OleStorage is None: logger.warning('%s: skipped', self.id()) return from hwp5.storage import unpack import shutil import os import os.path if os.path.exists('5017'): shutil.rmtree('5017') os.mkdir('5017') unpack(self.olestg, '5017') self.assertTrue(os.path.exists('5017/_05HwpSummaryInformation')) self.assertTrue(os.path.exists('5017/BinData/BIN0002.jpg')) self.assertTrue(os.path.exists('5017/BinData/BIN0002.png')) self.assertTrue(os.path.exists('5017/BinData/BIN0003.png')) self.assertTrue(os.path.exists('5017/BodyText/Section0')) self.assertTrue(os.path.exists('5017/DocInfo')) self.assertTrue(os.path.exists('5017/DocOptions/_LinkDoc')) self.assertTrue(os.path.exists('5017/FileHeader')) self.assertTrue(os.path.exists('5017/PrvImage')) self.assertTrue(os.path.exists('5017/PrvText')) self.assertTrue(os.path.exists('5017/Scripts/DefaultJScript')) self.assertTrue(os.path.exists('5017/Scripts/JScriptVersion'))
def extract_bindata_dir(hwp5file, bindata_dir): if 'BinData' not in hwp5file: return bindata_stg = hwp5file['BinData'] if not os.path.exists(bindata_dir): os.mkdir(bindata_dir) from hwp5.storage import unpack unpack(bindata_stg, bindata_dir)
def test_init_should_accept_fs(self): outpath = 'test_init_should_accept_fs' if os.path.exists(outpath): shutil.rmtree(outpath) os.mkdir(outpath) unpack(self.olestg, outpath) fs = FileSystemStorage(outpath) hwp5file = Hwp5File(fs) fileheader = hwp5file['FileHeader'] self.assertTrue(fileheader is not None) self.assertEquals((5, 0, 1, 7), fileheader.version)
def test_init_should_accept_fs(self): outpath = 'test_init_should_accept_fs' if os.path.exists(outpath): shutil.rmtree(outpath) os.mkdir(outpath) unpack(self.olestg, outpath) fs = FileSystemStorage(outpath) hwp5file = Hwp5File(fs) fileheader = hwp5file['FileHeader'] self.assertTrue(fileheader is not None) self.assertEqual((5, 0, 1, 7), fileheader.version)
def main(args): from hwp5 import storage from hwp5.proc import open_hwpfile import os.path filename = args['<hwp5file>'] hwp5file = open_hwpfile(args) outdir = args['<out-directory>'] if outdir is None: outdir, ext = os.path.splitext(os.path.basename(filename)) if not os.path.exists(outdir): os.mkdir(outdir) storage.unpack(hwp5file, outdir)
def test_init_should_accept_fs(self): from hwp5.filestructure import Hwp5File from hwp5.storage import unpack from hwp5.storage.fs import FileSystemStorage outpath = "test_init_should_accept_fs" if os.path.exists(outpath): shutil.rmtree(outpath) os.mkdir(outpath) unpack(self.olestg, outpath) fs = FileSystemStorage(outpath) hwp5file = Hwp5File(fs) fileheader = hwp5file["FileHeader"] self.assertTrue(fileheader is not None) self.assertEquals((5, 0, 1, 7), fileheader.version)
def test_unpack(self): outpath = 'test_unpack' if os.path.exists(outpath): shutil.rmtree(outpath) os.mkdir(outpath) unpack(ExtraItemStorage(self.hwp5file), outpath) self.assertTrue(os.path.exists('test_unpack/_05HwpSummaryInformation')) self.assertTrue(os.path.exists('test_unpack/BinData/BIN0002.jpg')) self.assertTrue(os.path.exists('test_unpack/BinData/BIN0002.png')) self.assertTrue(os.path.exists('test_unpack/BinData/BIN0003.png')) self.assertTrue(os.path.exists('test_unpack/BodyText/Section0')) self.assertTrue(os.path.exists('test_unpack/DocInfo')) self.assertTrue(os.path.exists('test_unpack/DocOptions/_LinkDoc')) self.assertTrue(os.path.exists('test_unpack/FileHeader')) self.assertTrue(os.path.exists('test_unpack/PrvImage')) self.assertTrue(os.path.exists('test_unpack/PrvText')) self.assertTrue(os.path.exists('test_unpack/PrvText.utf8')) self.assertTrue(os.path.exists('test_unpack/Scripts/DefaultJScript')) self.assertTrue(os.path.exists('test_unpack/Scripts/JScriptVersion'))
def test_unpack(self): if self.OleStorage is None: logger.warning('%s: skipped', self.id()) return if os.path.exists('5017'): shutil.rmtree('5017') os.mkdir('5017') unpack(self.olestg, '5017') self.assertTrue(os.path.exists('5017/_05HwpSummaryInformation')) self.assertTrue(os.path.exists('5017/BinData/BIN0002.jpg')) self.assertTrue(os.path.exists('5017/BinData/BIN0002.png')) self.assertTrue(os.path.exists('5017/BinData/BIN0003.png')) self.assertTrue(os.path.exists('5017/BodyText/Section0')) self.assertTrue(os.path.exists('5017/DocInfo')) self.assertTrue(os.path.exists('5017/DocOptions/_LinkDoc')) self.assertTrue(os.path.exists('5017/FileHeader')) self.assertTrue(os.path.exists('5017/PrvImage')) self.assertTrue(os.path.exists('5017/PrvText')) self.assertTrue(os.path.exists('5017/Scripts/DefaultJScript')) self.assertTrue(os.path.exists('5017/Scripts/JScriptVersion'))
def test_unpack(self): from hwp5.storage import ExtraItemStorage from hwp5.storage import unpack outpath = "test_unpack" if os.path.exists(outpath): shutil.rmtree(outpath) os.mkdir(outpath) unpack(ExtraItemStorage(self.hwp5file), outpath) self.assertTrue(os.path.exists("test_unpack/_05HwpSummaryInformation")) self.assertTrue(os.path.exists("test_unpack/BinData/BIN0002.jpg")) self.assertTrue(os.path.exists("test_unpack/BinData/BIN0002.png")) self.assertTrue(os.path.exists("test_unpack/BinData/BIN0003.png")) self.assertTrue(os.path.exists("test_unpack/BodyText/Section0")) self.assertTrue(os.path.exists("test_unpack/DocInfo")) self.assertTrue(os.path.exists("test_unpack/DocOptions/_LinkDoc")) self.assertTrue(os.path.exists("test_unpack/FileHeader")) self.assertTrue(os.path.exists("test_unpack/PrvImage")) self.assertTrue(os.path.exists("test_unpack/PrvText")) self.assertTrue(os.path.exists("test_unpack/PrvText.utf8")) self.assertTrue(os.path.exists("test_unpack/Scripts/DefaultJScript")) self.assertTrue(os.path.exists("test_unpack/Scripts/JScriptVersion"))