Skip to content

Commit 985c952

Browse files
authored
Add optional make_relative: bool to add_symlink_layer (#360)
* Add optional make_relative: bool to add_symlink_layer * format * update changelog
1 parent a6a9d5b commit 985c952

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1717

1818
### Fixed
1919

20+
## [0.8.2](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.2) - 2021-07-26
21+
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.1...HEAD)
22+
23+
### Breaking Changes in Config & CLI
24+
25+
### Added
26+
- Added option `make_relative: bool` to `wkcuber.api.dataset.Dataset.add_symlink_layer` to make the symlink relative. [#360](https://github.com/scalableminds/webknossos-cuber/pull/360)
27+
28+
### Changed
29+
30+
### Fixed
31+
2032
## [0.8.1](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.1) - 2021-07-22
2133
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.0...v0.8.1)
2234

wkcuber/api/dataset.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,19 @@ def delete_layer(self, layer_name: str) -> None:
408408
# delete files on disk
409409
rmtree(join(self.path, layer_name))
410410

411-
def add_symlink_layer(self, foreign_layer_path: Union[str, Path]) -> Layer:
411+
def add_symlink_layer(
412+
self, foreign_layer_path: Union[str, Path], make_relative: bool = False
413+
) -> Layer:
412414
"""
413415
Creates a symlink to the data at `foreign_layer_path` which belongs to another dataset.
414416
The relevant information from the `datasource-properties.json` of the other dataset is copied to this dataset.
415417
Note: If the other dataset modifies its bounding box afterwards, the change does not affect this properties
416418
(or vice versa).
419+
If make_relative is True, the symlink is made relative to the current dataset path.
417420
"""
418421
foreign_layer_path = Path(os.path.abspath(foreign_layer_path))
422+
if make_relative:
423+
foreign_layer_path = Path(os.path.relpath(foreign_layer_path, self.path))
419424
layer_name = foreign_layer_path.name
420425
if layer_name in self.layers.keys():
421426
raise IndexError(

0 commit comments

Comments
 (0)