decompress streams in the underlying storage
handle compressed streams in HWPv5 files
represents HWPv5 File
Hwp5File(stg)
stg: an instance of Storage
Base of an Hwp5File.
Hwp5FileBase checks basic validity of an HWP format v5 and provides fileheader property.
Parameters: | stg (an instance of storage, OleFileIO or filename) – an OLE2 structured storage. |
---|---|
Raises InvalidHwp5FileError: | |
stg is not a valid HWP format v5 document. |
Test whether it is an HWP format v5 file.
Hwp5File for ‘rec’ layer
group records by top-level trees and return iterable of the groups
convert a record to json
Initialize a context to parse the given record
the initializations includes followings: - context = dict(base) - context[‘record’] = record - context[‘stream’] = record payload stream
Parameters: |
|
---|---|
Returns: | new context |
convert a model to json
HWPTAG로 모델 결정 후 기본 파싱
inline extended-controls into paragraph texts
make paragraphs children of the listheader
lineseg/charshaped text chunks
Group table columns in each rows and wrap them with TableRow.
wrap a section with SectionDef
iterate every leaf nodes in the storage
stg: an instance of Storage
unpack a storage into outbase directory
stg: an instance of Storage outbase: path to a directory in filesystem (should not end with ‘/’)
decode utf-16le encoded bytes with Hanyang-PUA codes into a unicode string with Hangul Jamo codes
Parameters: | bytes – utf-16le encoded bytes with Hanyang-PUA codes |
---|---|
Returns: | a unicode string with Hangul Jamo codes |
from cStringIO/StringIO import StringIO
the equivalent of pkg_resources.resource_filename()
a fallback implementation of pkg_resources_filename()
build a tree from (event, item) stream
Example Scenario:
...
(STARTEVENT, rootitem) # should be consumed by the caller
--- call build_subtree() ---
(STARTEVENT, child1) # consumed by build_subtree()
(STARTEVENT, grandchild) # (same)
(ENDEVENT, grandchild) # (same)
(ENDEVENT, child1) # (same)
(STARTEVENT, child2) # (same)
(ENDEVENT, child2) # (same)
(ENDEVENT, rootitem) # same, buildsubtree() returns
--- build_subtree() returns ---
(STARTEVENT, another_root)
...
convert iterable of (event, item) into iterable of (ancestors, item)
convert iterable of (level, item) into iterable of (ancestors, item)
@param level_prefixed items: iterable of tuple(level, item) @return iterable of tuple(ancestors, item)
convert iterable of (level, item) into iterable of (event, item)
generate tuples of (event, item) from a tree
generate tuples of (event, item) from trees
convert a string generator into file-like reader
f = GeneratorReader(gen()) assert ‘hell’ == f.read(4) assert ‘oworld’ == f.read()
generate json array with given tokens