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 main(args): from hwp5.proc import open_hwpfile from hwp5.storage import open_storage_item import sys hwp5file = open_hwpfile(args) stream = open_storage_item(hwp5file, args['<stream>']) f = stream.open() try: while True: data = f.read(4096) if data: sys.stdout.write(data) else: return finally: if hasattr(f, 'close'): f.close()
def main(args): from hwp5.proc import open_hwpfile from hwp5.storage import open_storage_item import sys hwp5file = open_hwpfile(args) stream = open_storage_item(hwp5file, args['<stream>']) f = stream.open() try: while True: data = f.read(4096) if data: sys.stdout.write(data) else: return finally: if hasattr(f, 'close'): f.close() # Without this, last part of the output # can be truncated in Jython 2.5.3 # See #141 sys.stdout.close()
def main(args): from hwp5.storage import printstorage from hwp5.proc import open_hwpfile hwpfile = open_hwpfile(args) printstorage(hwpfile)