def open_hwpfile(args): from hwp5.xmlmodel import Hwp5File from hwp5.storage import ExtraItemStorage from hwp5.storage.ole import OleStorage filename = args['<hwp5file>'] if args['--ole']: hwpfile = OleStorage(filename) else: hwpfile = Hwp5File(filename) if args['--vstreams']: hwpfile = ExtraItemStorage(hwpfile) return hwpfile
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_if_hwp5file_contains_other_formats(self): stg = ExtraItemStorage(self.hwp5file) self.assertTrue('PrvText.utf8' in list(stg))
def test_bodytext(self): bodytext = self.hwp5file.bodytext self.assertTrue(isinstance(bodytext, RS.Sections)) stg = ExtraItemStorage(bodytext) self.assertEqual(['Section0', 'Section0.records'], list(stg))
def test_if_hwp5file_contains_other_formats(self): stg = ExtraItemStorage(self.hwp5file) self.assertTrue('DocInfo.records' in list(stg))