add field for tracking location
add tracking of external link locations
write links in write_builder
add tests
clean up flake8, and use function for getting temp filepath
Showing 2 of 3 files from the diff.
Newly tracked file
src/hdmf/backends/hdf5/h5tools.py
changed.
Newly tracked file
src/hdmf/build/builders.py
changed.
Other files ignored by Codecov
tests/unit/test_io_hdf5_h5tools.py
has changed.
@@ -310,6 +310,7 @@
Loading
310 | 310 | # get path of link (the key used for tracking what's been built) |
|
311 | 311 | target_path = link_type.path |
|
312 | 312 | builder_name = os.path.basename(target_path) |
|
313 | + | parent_loc = os.path.dirname(target_path) |
|
313 | 314 | # get builder if already read, else build it |
|
314 | 315 | builder = self.__get_built(sub_h5obj.file.filename, target_path) |
|
315 | 316 | if builder is None: |
@@ -319,6 +320,7 @@
Loading
319 | 320 | else: |
|
320 | 321 | builder = self.__read_group(sub_h5obj, builder_name, ignore=ignore) |
|
321 | 322 | self.__set_built(sub_h5obj.file.filename, target_path, builder) |
|
323 | + | builder.location = parent_loc |
|
322 | 324 | link_builder = LinkBuilder(builder, k, source=h5obj.file.filename) |
|
323 | 325 | link_builder.written = True |
|
324 | 326 | kwargs['links'][builder_name] = link_builder |
@@ -446,6 +448,8 @@
Loading
446 | 448 | self.write_group(self.__file, gbldr) |
|
447 | 449 | for name, dbldr in f_builder.datasets.items(): |
|
448 | 450 | self.write_dataset(self.__file, dbldr, link_data) |
|
451 | + | for name, lbldr in f_builder.links.items(): |
|
452 | + | self.write_link(self.__file, lbldr) |
|
449 | 453 | self.set_attributes(self.__file, f_builder.attributes) |
|
450 | 454 | self.__add_refs() |
|
451 | 455 |
@@ -632,6 +636,8 @@
Loading
632 | 636 | target_filename = os.path.abspath(target_builder.source) |
|
633 | 637 | parent_filename = os.path.abspath(parent.file.filename) |
|
634 | 638 | relative_path = os.path.relpath(target_filename, os.path.dirname(parent_filename)) |
|
639 | + | if target_builder.location is not None: |
|
640 | + | path = target_builder.location + path |
|
635 | 641 | link_obj = ExternalLink(relative_path, path) |
|
636 | 642 | else: |
|
637 | 643 | msg = 'cannot create external link to %s' % path |
@@ -104,6 +104,18 @@
Loading
104 | 104 | super(BaseBuilder, self).__setitem__(BaseBuilder.__attribute, dict()) |
|
105 | 105 | for name, val in attributes.items(): |
|
106 | 106 | self.set_attribute(name, val) |
|
107 | + | self.__location = None |
|
108 | + | ||
109 | + | @property |
|
110 | + | def location(self): |
|
111 | + | """ |
|
112 | + | The location of this Builder in its source |
|
113 | + | """ |
|
114 | + | return self.__location |
|
115 | + | ||
116 | + | @location.setter |
|
117 | + | def location(self, val): |
|
118 | + | self.__location = val |
|
107 | 119 | ||
108 | 120 | @property |
|
109 | 121 | def attributes(self): |
Files | Coverage |
---|---|
src/hdmf | 68.71% |
Project Totals (24 files) | 68.71% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.