コード例 #1
0
ファイル: __init__.py プロジェクト: yarang/pyhwp
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)
コード例 #2
0
ファイル: __init__.py プロジェクト: ParanScreen/dimidisk-hwp
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)
コード例 #3
0
ファイル: cat.py プロジェクト: ParanScreen/dimidisk-hwp
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()
コード例 #4
0
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()