Skip to content

Commit fbee1a3

Browse files
committed
allow passing a filemetadata to manifesttree.
1 parent d1e4cfd commit fbee1a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ccnpy/flic/ManifestTree.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ def __init__(self, data_input, packet_output: PacketWriter, tree_options: Manife
3838
If `tree_options.max_tree_degree` is not given, it will pick a degree that minimizes the wasted space
3939
in the tree.
4040
41-
:param data_input: Something we can call read() on that returns byte arrays, e.g. open(filename, 'rb')
41+
:param data_input: Something we can call read() on, or a FileMetadata
4242
:param packet_output: Something we can call put(ccnpy.Packet) on to output packets (see .tree.TreeIO)
4343
:param tree_options:
4444
:param manifest_graph: If not None, will be filled in as we build the tree
4545
"""
46-
self._data_input = data_input
4746
self._packet_output = packet_output
4847
self._tree_options = tree_options
4948
self._name_ctx = NameConstructorContext.create(self._tree_options)
5049
self._manifest_graph = manifest_graph
51-
self._file_metadata = self._name_ctx.data_schema_impl.chunk_data(self._data_input, self._packet_output)
50+
if isinstance(data_input, FileMetadata):
51+
self._file_metadata = data_input
52+
else:
53+
self._file_metadata = self._name_ctx.data_schema_impl.chunk_data(data_input, self._packet_output)
5254
self._manifest_factory = ManifestFactory(tree_options=self._tree_options, manifest_graph=self._manifest_graph)
5355
self._optimized_params = self._calculate_optimal_tree(file_metadata=self._file_metadata, manifest_factory=self._manifest_factory)
5456

0 commit comments

Comments
 (0)