Esempio n. 1
0
 def test_basic(self):
     from unokit.adapters import InputStreamFromFileLike
     from hwp5_uno import HwpFileFromInputStream
     with self.open_fixture('sample-5017.hwp', 'rb') as f:
         inputstream = InputStreamFromFileLike(f)
         hwpfile = HwpFileFromInputStream(inputstream)
         self.assertEqual((5, 0, 1, 7), hwpfile.fileheader.version)
Esempio n. 2
0
    def test_basic(self):
        import uno
        from unokit.adapters import InputStreamFromFileLike
        from hwp5_uno import StorageFromInputStream
        from hwp5.hwp5odt import ODTPackage

        zipname = self.id()+'.zip'

        pkg = ODTPackage(zipname)
        try:
            from StringIO import StringIO
            data = StringIO('hello')
            pkg.insert_stream(data, 'abc.txt', 'text/plain')
        finally:
            pkg.close()

        with file(zipname, 'rb') as f:
            inputstream = InputStreamFromFileLike(f, dontclose=True)
            storage = StorageFromInputStream(inputstream)
            try:
                self.assertTrue(uno.getTypeByName('com.sun.star.embed.XStorage')
                                in storage.Types)
                self.assertEqual(set(['abc.txt']), set(storage.ElementNames))
            finally:
                storage.dispose()
Esempio n. 3
0
 def test_basic(self):
     from unokit.adapters import InputStreamFromFileLike
     from hwp5_uno import inputstream_is_hwp5file
     from hwp5_uno import typedetect
     with self.open_fixture('sample-5017.hwp', 'rb') as f:
         inputstream = InputStreamFromFileLike(f, dontclose=True)
         self.assertTrue(inputstream_is_hwp5file(inputstream))
         self.assertEqual('hwp5', typedetect(inputstream))
Esempio n. 4
0
 def get_adapter(self):
     from unokit.services import css
     from hwp5_uno import InputStreamFromFileLike
     from hwp5_uno import OleStorageAdapter
     f = self.open_fixture('sample-5017.hwp', 'rb')
     inputstream = InputStreamFromFileLike(f)
     oless = css.embed.OLESimpleStorage(inputstream)
     return OleStorageAdapter(oless)