dazzle-filekit 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/PKG-INFO +1 -1
  2. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/__init__.py +3 -1
  3. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/links.py +40 -0
  4. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit.egg-info/PKG-INFO +1 -1
  5. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/pyproject.toml +1 -1
  6. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_import_stability.py +2 -0
  7. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_link_primitives.py +51 -0
  8. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/LICENSE +0 -0
  9. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/README.md +0 -0
  10. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/_fallback.py +0 -0
  11. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/content.py +0 -0
  12. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/metadata.py +0 -0
  13. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/operations.py +0 -0
  14. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/paths.py +0 -0
  15. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/platform/__init__.py +0 -0
  16. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/platform/unix.py +0 -0
  17. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/platform/windows.py +0 -0
  18. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/utils/__init__.py +0 -0
  19. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/utils/compat.py +0 -0
  20. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/utils/disk.py +0 -0
  21. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/utils/logger.py +0 -0
  22. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/utils/validation.py +0 -0
  23. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit/verification.py +0 -0
  24. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit.egg-info/SOURCES.txt +0 -0
  25. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit.egg-info/dependency_links.txt +0 -0
  26. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit.egg-info/requires.txt +0 -0
  27. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/dazzle_filekit.egg-info/top_level.txt +0 -0
  28. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/setup.cfg +0 -0
  29. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/setup.py +0 -0
  30. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_ads_and_junction_v024.py +0 -0
  31. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_auto_naming.py +0 -0
  32. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_compat.py +0 -0
  33. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_content_and_process.py +0 -0
  34. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_disk.py +0 -0
  35. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_fallback.py +0 -0
  36. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_metadata_v024_roundtrip.py +0 -0
  37. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_operations_primitives_v024.py +0 -0
  38. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_paths_platform_simulation.py +0 -0
  39. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_paths_v024_enrichments.py +0 -0
  40. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_phase_b_absorb_and_v9.py +0 -0
  41. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_phase_c_renames.py +0 -0
  42. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_phase_d_typeddicts.py +0 -0
  43. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_resolver_ops.py +0 -0
  44. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_smoke.py +0 -0
  45. {dazzle_filekit-0.3.1 → dazzle_filekit-0.3.2}/tests/test_symlink_timestamps_v031.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dazzle-filekit
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Cross-platform file operations toolkit with path handling, verification, and metadata preservation
5
5
  Author: Dustin
6
6
  Author-email: Dustin Darcy <6962246+djdarcy@users.noreply.github.com>
@@ -116,9 +116,10 @@ from .links import (
116
116
  read_link_target,
117
117
  create_junction,
118
118
  create_hardlink,
119
+ remove_link,
119
120
  )
120
121
 
121
- __version__ = '0.3.1'
122
+ __version__ = '0.3.2'
122
123
 
123
124
  def configure_logging(level=logging.INFO, log_file=None):
124
125
  """
@@ -256,6 +257,7 @@ __all__ = [
256
257
  'read_link_target',
257
258
  'create_junction',
258
259
  'create_hardlink',
260
+ 'remove_link',
259
261
 
260
262
  # Verification functions
261
263
  'calculate_file_hash',
@@ -316,3 +316,43 @@ def create_hardlink(
316
316
  else:
317
317
  logger.error(f"Failed to create hard link {link_path}: {e}")
318
318
  return False
319
+
320
+
321
+ def remove_link(path: Union[str, Path]) -> bool:
322
+ """Remove (detach) a symlink, junction, or hard link WITHOUT deleting its
323
+ target.
324
+
325
+ The inverse of :func:`create_junction` / :func:`create_hardlink` /
326
+ :func:`create_symlink`:
327
+
328
+ * a **junction** is detached with ``os.rmdir`` -- the reparse point is
329
+ removed, the target directory tree is left untouched;
330
+ * a **directory symlink** (Windows) is likewise removed with ``os.rmdir``;
331
+ a **file symlink** with ``unlink`` -- the target file stays;
332
+ * a **hard link** is removed with ``unlink``, which only decrements the
333
+ file's link count (the data survives while another name remains).
334
+
335
+ Returns True on success, False if ``path`` is not a link or removal fails
336
+ (the reason is logged). Ported from preservelib (R7); the conservation
337
+ verdict returned this intrinsic link primitive to its L1 home.
338
+ """
339
+ p = Path(path)
340
+ kind = detect_link_type(p)
341
+ if kind is None:
342
+ logger.error(f"remove_link: not a link: {p}")
343
+ return False
344
+ try:
345
+ if kind == LINK_JUNCTION:
346
+ os.rmdir(p) # detach junction; target tree untouched
347
+ elif kind == LINK_SYMLINK:
348
+ if p.is_dir():
349
+ os.rmdir(p) # directory symlink (Windows)
350
+ else:
351
+ p.unlink() # file symlink
352
+ elif kind == LINK_HARDLINK:
353
+ p.unlink() # decrements the file's link count
354
+ logger.debug(f"Removed {kind} link: {p}")
355
+ return True
356
+ except OSError as e:
357
+ logger.error(f"remove_link({p}) failed: {e}")
358
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dazzle-filekit
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Cross-platform file operations toolkit with path handling, verification, and metadata preservation
5
5
  Author: Dustin
6
6
  Author-email: Dustin Darcy <6962246+djdarcy@users.noreply.github.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dazzle-filekit"
7
- version = "0.3.1"
7
+ version = "0.3.2"
8
8
  description = "Cross-platform file operations toolkit with path handling, verification, and metadata preservation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -66,6 +66,7 @@ TOP_LEVEL_LOCKED = [
66
66
  "read_link_target",
67
67
  "create_junction",
68
68
  "create_hardlink",
69
+ "remove_link",
69
70
  "compute_relative_path",
70
71
  "links", # the submodule
71
72
  ]
@@ -142,6 +143,7 @@ SUBMODULE_LOCKED = {
142
143
  "read_link_target",
143
144
  "create_junction",
144
145
  "create_hardlink",
146
+ "remove_link",
145
147
  ],
146
148
  "dazzle_filekit.utils.validation": [
147
149
  "is_junction",
@@ -30,6 +30,7 @@ from dazzle_filekit import (
30
30
  detect_link_type,
31
31
  get_relative_path,
32
32
  read_link_target,
33
+ remove_link,
33
34
  )
34
35
  from dazzle_filekit import links as links_mod
35
36
 
@@ -250,3 +251,53 @@ def test_no_cmd_shellouts_in_link_module():
250
251
  "link primitives must not shell out to cmd.exe (use PowerShell / DeviceIoControl)"
251
252
  )
252
253
  assert "powershell" in source.lower()
254
+
255
+
256
+ # ---------------------------------------------------------------------------
257
+ # AC-5 (R7): remove_link detaches a link WITHOUT deleting its target
258
+ # ---------------------------------------------------------------------------
259
+
260
+
261
+ def test_remove_link_not_a_link_returns_false(tmp_path):
262
+ f = tmp_path / "plain.txt"
263
+ f.write_text("data")
264
+ assert remove_link(f) is False
265
+ assert f.exists() # a real file is never removed
266
+
267
+
268
+ def test_remove_link_file_symlink_keeps_target(tmp_path):
269
+ target = tmp_path / "t.txt"
270
+ target.write_text("payload")
271
+ link = tmp_path / "s.txt"
272
+ if not _try_symlink(target, link):
273
+ pytest.skip("symlink privilege not available")
274
+ assert detect_link_type(link) == "symlink"
275
+ assert remove_link(link) is True
276
+ assert not link.exists() # link detached
277
+ assert target.read_text() == "payload" # target file survives
278
+
279
+
280
+ def test_remove_link_hardlink_keeps_data(tmp_path):
281
+ src = tmp_path / "file.txt"
282
+ src.write_text("hard data")
283
+ link = tmp_path / "hard.txt"
284
+ if not create_hardlink(src, link):
285
+ pytest.skip("hard links not supported on this filesystem")
286
+ assert remove_link(link) is True
287
+ assert not link.exists() # the second name is gone
288
+ assert src.read_text() == "hard data" # data survives via the original name
289
+
290
+
291
+ @pytest.mark.skipif(sys.platform != "win32", reason="junctions are Windows-only")
292
+ def test_remove_link_junction_keeps_target_tree(tmp_path):
293
+ target = tmp_path / "target"
294
+ target.mkdir()
295
+ (target / "inside.txt").write_text("keepme")
296
+ link = tmp_path / "jct"
297
+ if not create_junction(target, link):
298
+ pytest.skip("could not create junction in this environment")
299
+ assert detect_link_type(link) == "junction"
300
+ assert remove_link(link) is True
301
+ assert not link.exists() # junction detached
302
+ assert target.is_dir() # target dir survives
303
+ assert (target / "inside.txt").read_text() == "keepme" # contents intact
File without changes
File without changes
File without changes
File without changes