Skip to content

Commit

Permalink
Remove support for symbolic links
Browse files Browse the repository at this point in the history
  • Loading branch information
yuce committed Oct 13, 2024
1 parent 362860d commit 7d9071f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/pyswip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ def resolve_path(filename: str, relative_to: Union[str, Path] = "") -> Path:
relative_to = Path(relative_to)
if not relative_to.exists():
raise FileNotFoundError(
None, "resolve_filename: relative_to does not exist", str(relative_to)
None, "Relative path does not exist", str(relative_to)
)
if relative_to.is_symlink():
try:
relative_to = relative_to.readlink()
except NotImplementedError:
pass
raise ValueError("Symbolic links are not supported")
if relative_to.is_dir():
return relative_to / filename
elif relative_to.is_file():
Expand Down
5 changes: 1 addition & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ def test_resolve_path_given_dir(self):
self.assertEqual(current_dir / filename, path)

def test_resolve_path_symbolic_link(self):
if sys.platform == "win32":
self.skipTest("this feature is supported only on UNIX")
current_dir = Path(__file__).parent.absolute()
path = current_dir / "test_read.pl"
temp_dir = tempfile.TemporaryDirectory("pyswip")
try:
symlink = Path(temp_dir.name) / "symlinked"
os.symlink(path, symlink)
resolved_path = resolve_path("test_read.pl", symlink)
self.assertEqual(path, resolved_path)
self.assertRaises(ValueError, lambda: resolve_path("test_read.pl", symlink))
finally:
temp_dir.cleanup()

0 comments on commit 7d9071f

Please sign in to comment.