causalcore 0.1.0a1__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.
- causalcore-0.1.0a1/LICENSE +21 -0
- causalcore-0.1.0a1/PKG-INFO +40 -0
- causalcore-0.1.0a1/README.md +27 -0
- causalcore-0.1.0a1/pyproject.toml +24 -0
- causalcore-0.1.0a1/setup.cfg +4 -0
- causalcore-0.1.0a1/src/causalcore.egg-info/PKG-INFO +40 -0
- causalcore-0.1.0a1/src/causalcore.egg-info/SOURCES.txt +10 -0
- causalcore-0.1.0a1/src/causalcore.egg-info/dependency_links.txt +1 -0
- causalcore-0.1.0a1/src/causalcore.egg-info/entry_points.txt +2 -0
- causalcore-0.1.0a1/src/causalcore.egg-info/top_level.txt +1 -0
- causalcore-0.1.0a1/src/causalcore.py +26 -0
- causalcore-0.1.0a1/tests/test_sha256.py +33 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: causalcore
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Streaming SHA-256 file checksums
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# causalcore
|
|
15
|
+
|
|
16
|
+
Version 0.1.0a1 is a standalone SHA-256 file checksum utility. It hashes files
|
|
17
|
+
incrementally using the Python standard library. This alpha has no
|
|
18
|
+
causal-inference or machine learning functionality. Python 3.11 or later; no third-party dependencies.
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
python -m pip install causalcore==0.1.0a1
|
|
22
|
+
causalcore archive.zip
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from causalcore import sha256_file
|
|
27
|
+
|
|
28
|
+
digest = sha256_file("archive.zip")
|
|
29
|
+
print(digest) # 64 lowercase hexadecimal characters
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Files are opened in binary mode. `sha256_file` accepts a string or pathlib.Path,
|
|
33
|
+
returns the digest, and lets filesystem errors propagate to the caller. The
|
|
34
|
+
command prints a JSON object with `path` and `sha256`; filesystem errors go to
|
|
35
|
+
stderr with exit status 2. `python -m causalcore` is also supported.
|
|
36
|
+
|
|
37
|
+
A checksum verifies equality against a known digest; it does not establish who
|
|
38
|
+
created a file or whether a file is trustworthy.
|
|
39
|
+
|
|
40
|
+
The API may change during alpha development. Licensed under MIT; see LICENSE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# causalcore
|
|
2
|
+
|
|
3
|
+
Version 0.1.0a1 is a standalone SHA-256 file checksum utility. It hashes files
|
|
4
|
+
incrementally using the Python standard library. This alpha has no
|
|
5
|
+
causal-inference or machine learning functionality. Python 3.11 or later; no third-party dependencies.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
python -m pip install causalcore==0.1.0a1
|
|
9
|
+
causalcore archive.zip
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from causalcore import sha256_file
|
|
14
|
+
|
|
15
|
+
digest = sha256_file("archive.zip")
|
|
16
|
+
print(digest) # 64 lowercase hexadecimal characters
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Files are opened in binary mode. `sha256_file` accepts a string or pathlib.Path,
|
|
20
|
+
returns the digest, and lets filesystem errors propagate to the caller. The
|
|
21
|
+
command prints a JSON object with `path` and `sha256`; filesystem errors go to
|
|
22
|
+
stderr with exit status 2. `python -m causalcore` is also supported.
|
|
23
|
+
|
|
24
|
+
A checksum verifies equality against a known digest; it does not establish who
|
|
25
|
+
created a file or whether a file is trustworthy.
|
|
26
|
+
|
|
27
|
+
The API may change during alpha development. Licensed under MIT; see LICENSE.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "causalcore"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "Streaming SHA-256 file checksums"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
causalcore = "causalcore:main"
|
|
21
|
+
|
|
22
|
+
[tool.setuptools]
|
|
23
|
+
py-modules = ["causalcore"]
|
|
24
|
+
package-dir = {"" = "src"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: causalcore
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Streaming SHA-256 file checksums
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# causalcore
|
|
15
|
+
|
|
16
|
+
Version 0.1.0a1 is a standalone SHA-256 file checksum utility. It hashes files
|
|
17
|
+
incrementally using the Python standard library. This alpha has no
|
|
18
|
+
causal-inference or machine learning functionality. Python 3.11 or later; no third-party dependencies.
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
python -m pip install causalcore==0.1.0a1
|
|
22
|
+
causalcore archive.zip
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from causalcore import sha256_file
|
|
27
|
+
|
|
28
|
+
digest = sha256_file("archive.zip")
|
|
29
|
+
print(digest) # 64 lowercase hexadecimal characters
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Files are opened in binary mode. `sha256_file` accepts a string or pathlib.Path,
|
|
33
|
+
returns the digest, and lets filesystem errors propagate to the caller. The
|
|
34
|
+
command prints a JSON object with `path` and `sha256`; filesystem errors go to
|
|
35
|
+
stderr with exit status 2. `python -m causalcore` is also supported.
|
|
36
|
+
|
|
37
|
+
A checksum verifies equality against a known digest; it does not establish who
|
|
38
|
+
created a file or whether a file is trustworthy.
|
|
39
|
+
|
|
40
|
+
The API may change during alpha development. Licensed under MIT; see LICENSE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/causalcore.py
|
|
5
|
+
src/causalcore.egg-info/PKG-INFO
|
|
6
|
+
src/causalcore.egg-info/SOURCES.txt
|
|
7
|
+
src/causalcore.egg-info/dependency_links.txt
|
|
8
|
+
src/causalcore.egg-info/entry_points.txt
|
|
9
|
+
src/causalcore.egg-info/top_level.txt
|
|
10
|
+
tests/test_sha256.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
causalcore
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Compute a file's SHA-256 checksum without loading it into memory."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def sha256_file(path: str | Path) -> str:
|
|
10
|
+
"""Return a file's lowercase hexadecimal SHA-256 digest."""
|
|
11
|
+
with open(path, "rb") as stream:
|
|
12
|
+
return hashlib.file_digest(stream, "sha256").hexdigest()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main() -> None:
|
|
16
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
17
|
+
parser.add_argument("path", help="file to checksum")
|
|
18
|
+
args = parser.parse_args()
|
|
19
|
+
try:
|
|
20
|
+
print(json.dumps({"path": args.path, "sha256": sha256_file(args.path)}))
|
|
21
|
+
except OSError as error:
|
|
22
|
+
parser.error(str(error))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
main()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
from causalcore import sha256_file
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChecksumTests(unittest.TestCase):
|
|
13
|
+
def test_empty_binary_and_cli(self):
|
|
14
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
15
|
+
path = Path(directory) / "file.bin"
|
|
16
|
+
for data in (b"", bytes(range(256)) * 4096):
|
|
17
|
+
path.write_bytes(data)
|
|
18
|
+
expected = hashlib.sha256(data).hexdigest()
|
|
19
|
+
self.assertEqual(sha256_file(path), expected)
|
|
20
|
+
result = subprocess.run([sys.executable, "-m", "causalcore", str(path)],
|
|
21
|
+
text=True, capture_output=True)
|
|
22
|
+
self.assertEqual(result.returncode, 0, result.stderr)
|
|
23
|
+
self.assertEqual(json.loads(result.stdout), dict(path=str(path), sha256=expected))
|
|
24
|
+
|
|
25
|
+
def test_missing_file(self):
|
|
26
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
27
|
+
path = str(Path(directory) / "missing")
|
|
28
|
+
with self.assertRaises(FileNotFoundError):
|
|
29
|
+
sha256_file(path)
|
|
30
|
+
result = subprocess.run([sys.executable, "-m", "causalcore", path],
|
|
31
|
+
text=True, capture_output=True)
|
|
32
|
+
self.assertEqual(result.returncode, 2)
|
|
33
|
+
self.assertNotIn("Traceback", result.stderr)
|