Skip to content

Commit

Permalink
Use text-based link relation by default
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Mar 1, 2024
1 parent 02c199f commit 015ca21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

# Unreleased

- Use text-based link relation by default

# v4.9.0

- Adds `Interface.related_iterator()`

# v4.9.0
Expand Down
8 changes: 6 additions & 2 deletions src/machinable/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ def _wrapper(
belongs_to_many = _relation(BelongsToMany)


def _uuid_symlink(directory, uuid):
def _uuid_symlink(directory, uuid, mode="file"):
dst = os.path.join(directory, id_from_uuid(uuid))
try:
os.makedirs(dst, exist_ok=True)
os.symlink("../../" + uuid, os.path.join(dst, "link"))
if mode == "file":
with open(os.path.join(dst, "link"), "w") as f:
f.write("../../" + uuid)
else:
os.symlink("../../" + uuid, os.path.join(dst, "link"))
except OSError:
pass

Expand Down
4 changes: 1 addition & 3 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ def test_symlink_relations(tmp_storage):
project = Project("./tests/samples/project").__enter__()

component = get("dummy").launch()
assert os.path.isfile(
component.execution.component_directory("link", ".machinable")
)
assert os.path.isfile(component.execution.component_directory("link"))

project.__exit__()

Expand Down

0 comments on commit 015ca21

Please sign in to comment.