package hwp5¶
module hwp5.filestructure¶
module hwp5.recordstream¶
module hwp5.binmodel¶
module hwp5.xmlmodel¶
module hwp5.xmlformat¶
module hwp5.storage¶
- hwp5.storage.iter_storage_leafs(stg, basepath='')¶
iterate every leaf nodes in the storage
stg: an instance of Storage
- hwp5.storage.unpack(stg, outbase)¶
unpack a storage into outbase directory
stg: an instance of Storage outbase: path to a directory in filesystem (should not end with ‘/’)
module hwp5.dataio¶
module hwp5.tagids¶
module hwp5.plat¶
module hwp5.importhelper¶
- hwp5.importhelper.pkg_resources_filename(pkg_name, path)¶
the equivalent of pkg_resources.resource_filename()
- hwp5.importhelper.pkg_resources_filename_fallback(pkg_name, path)¶
a fallback implementation of pkg_resources_filename()
module hwp5.treeop¶
- hwp5.treeop.build_subtree(event_prefixed_items)¶
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) ...
- result will be (rootitem, [(child1, [(grandchild, [])]),
(child2, [])])
- hwp5.treeop.prefix_ancestors(event_prefixed_items, root_item=None)¶
convert iterable of (event, item) into iterable of (ancestors, item)
- hwp5.treeop.prefix_ancestors_from_level(level_prefixed_items, root_item=None)¶
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)
- hwp5.treeop.prefix_event(level_prefixed_items, root_item=None)¶
convert iterable of (level, item) into iterable of (event, item)
- hwp5.treeop.tree_events(rootitem, childs)¶
generate tuples of (event, item) from a tree
- hwp5.treeop.tree_events_multi(trees)¶
generate tuples of (event, item) from trees
module hwp5.utils¶
- class hwp5.utils.GeneratorReader(gen)¶
convert a string generator into file-like reader
- def gen():
yield b’hello’ yield b’world’
f = GeneratorReader(gen()) assert ‘hell’ == f.read(4) assert ‘oworld’ == f.read()
- class hwp5.utils.GeneratorTextReader(gen)¶
convert a string generator into file-like reader
- def gen():
yield ‘hello’ yield ‘world’
f = GeneratorTextReader(gen()) assert ‘hell’ == f.read(4) assert ‘oworld’ == f.read()
- hwp5.utils.generate_json_array(tokens)¶
generate json array with given tokens
- hwp5.utils.unicode_escape(s)¶
Escape a string.
- Parameters:
s (unicode) – a string to escape
- Returns:
escaped string
- Return type:
unicode
- hwp5.utils.unicode_unescape(s)¶
Unescape a string.
- Parameters:
s (unicode) – a string to unescape
- Returns:
unescaped string
- Return type:
unicode