def parse_recordstream_name(hwpfile, streamname): from hwp5.storage import open_storage_item if streamname == 'docinfo': return hwpfile.docinfo segments = streamname.split('/') if len(segments) == 2: if segments[0] == 'bodytext': try: idx = int(segments[1]) return hwpfile.bodytext.section(idx) except ValueError: pass return open_storage_item(hwpfile, streamname)
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()