claims-cli 0.6.0__py3-none-any.whl

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 (51) hide show
  1. claims/__init__.py +132 -0
  2. claims/__main__.py +5 -0
  3. claims/adapters/__init__.py +6 -0
  4. claims/adapters/array.py +212 -0
  5. claims/adapters/base.py +75 -0
  6. claims/adapters/cells.py +94 -0
  7. claims/adapters/columnar.py +188 -0
  8. claims/adapters/prose.py +261 -0
  9. claims/adapters/reads.py +47 -0
  10. claims/adapters/rows.py +116 -0
  11. claims/adapters/sheet.py +149 -0
  12. claims/adapters/sqlite.py +73 -0
  13. claims/adapters/table.py +135 -0
  14. claims/adapters/tree.py +163 -0
  15. claims/checks.py +511 -0
  16. claims/cli.py +1103 -0
  17. claims/core/__init__.py +9 -0
  18. claims/core/artifacts.py +121 -0
  19. claims/core/checks.py +132 -0
  20. claims/core/claims.py +100 -0
  21. claims/core/evidence.py +708 -0
  22. claims/core/manifest.py +349 -0
  23. claims/core/numbers.py +146 -0
  24. claims/core/outcomes.py +410 -0
  25. claims/core/report.py +503 -0
  26. claims/corpus.py +344 -0
  27. claims/exceptions.py +106 -0
  28. claims/export/__init__.py +23 -0
  29. claims/export/rocrate.py +787 -0
  30. claims/export/sarif.py +401 -0
  31. claims/manifest.py +59 -0
  32. claims/models.py +222 -0
  33. claims/numbers.py +453 -0
  34. claims/origins.py +303 -0
  35. claims/policy.py +369 -0
  36. claims/provenance.py +42 -0
  37. claims/record.py +1099 -0
  38. claims/regression.py +171 -0
  39. claims/renderers/__init__.py +10 -0
  40. claims/renderers/sarif.py +294 -0
  41. claims/reruns.py +111 -0
  42. claims/resolve.py +116 -0
  43. claims/stale.py +333 -0
  44. claims/starter.py +432 -0
  45. claims/toolchain.py +120 -0
  46. claims/verify.py +1371 -0
  47. claims/why.py +398 -0
  48. claims_cli-0.6.0.dist-info/METADATA +139 -0
  49. claims_cli-0.6.0.dist-info/RECORD +51 -0
  50. claims_cli-0.6.0.dist-info/WHEEL +4 -0
  51. claims_cli-0.6.0.dist-info/entry_points.txt +2 -0
claims/provenance.py ADDED
@@ -0,0 +1,42 @@
1
+ """Reading a working tree's revision, for the record.
2
+
3
+ This never verifies anything. A commit identifies a tree; the pin that establishes what was
4
+ read is the artifact's own digest. What a commit buys is the ability to go and fetch the same
5
+ bytes, which the digest then confirms.
6
+
7
+ A dirty working tree is recorded as dirty rather than silently attributed to the commit it
8
+ sits on, because a manifest built from uncommitted changes names a revision that does not
9
+ contain what was read.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import pathlib
15
+
16
+ from provenance_core.gitref import try_run
17
+
18
+ from claims.models import Provenance
19
+
20
+
21
+ def _git(args: list[str], cwd: pathlib.Path) -> str | None:
22
+ """Run one git command, or None when git is absent or the directory is not a repository."""
23
+ return try_run(*args, cwd=cwd)
24
+
25
+
26
+ def of_tree(path: pathlib.Path, generated_by: str = "") -> Provenance:
27
+ """Where the files under `path` came from, as far as git can say.
28
+
29
+ Returns a `Provenance` with empty fields rather than raising when the directory is not a
30
+ repository: a manifest over loose files is legitimate, and it should say that it has no
31
+ revision rather than fail to be written.
32
+ """
33
+ root = path if path.is_dir() else path.parent
34
+ commit = _git(["rev-parse", "HEAD"], root) or ""
35
+ remote = _git(["remote", "get-url", "origin"], root) or ""
36
+ status = _git(["status", "--porcelain"], root)
37
+ return Provenance(
38
+ repository=remote or (str(root) if commit else ""),
39
+ commit=commit,
40
+ dirty=bool(status),
41
+ generated_by=generated_by,
42
+ )