cyfer 0.1.1__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.
- cyfer-0.1.1/LICENSE +22 -0
- cyfer-0.1.1/PKG-INFO +42 -0
- cyfer-0.1.1/README.md +25 -0
- cyfer-0.1.1/cyfer/__init__.py +3 -0
- cyfer-0.1.1/cyfer/core/__init__.py +0 -0
- cyfer-0.1.1/cyfer/core/gpg_context.py +132 -0
- cyfer-0.1.1/pyproject.toml +22 -0
cyfer-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Dylan Garrett
|
|
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.
|
|
22
|
+
|
cyfer-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cyfer
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A package for doing great things!
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Dylan Garrett
|
|
8
|
+
Requires-Python: >=3.13,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: cryptography (>=49.0.0,<50.0.0)
|
|
14
|
+
Requires-Dist: python-gnupg (>=0.5.6,<0.6.0)
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# cyfer
|
|
18
|
+
|
|
19
|
+
A package for doing great things!
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ pip install cyfer
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
- TODO
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
`cyfer` was created by Dylan Garrett. It is licensed under the terms of the MIT license.
|
|
38
|
+
|
|
39
|
+
## Credits
|
|
40
|
+
|
|
41
|
+
`cyfer` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).
|
|
42
|
+
|
cyfer-0.1.1/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# cyfer
|
|
2
|
+
|
|
3
|
+
A package for doing great things!
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ pip install cyfer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
- TODO
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
`cyfer` was created by Dylan Garrett. It is licensed under the terms of the MIT license.
|
|
22
|
+
|
|
23
|
+
## Credits
|
|
24
|
+
|
|
25
|
+
`cyfer` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).
|
|
File without changes
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""
|
|
2
|
+
cyfer/core/gpg_context.py
|
|
3
|
+
=========================
|
|
4
|
+
GPG context setup and configuration.
|
|
5
|
+
|
|
6
|
+
This is the foundation every other module imports from. It handles:
|
|
7
|
+
- Locating (or creating) a keyring directory
|
|
8
|
+
- Instantiating a python-gnupg GPG object with some defaults
|
|
9
|
+
- Verifying the gpg binary is reachable
|
|
10
|
+
- Exposing a ready-to-use GPG instance + a lightweight result inspector
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
import gnupg
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
DEFAULT_GNUPGHOME = Path(__file__).parent / "test_keyring"
|
|
23
|
+
|
|
24
|
+
GPG_BINARY = "gpg"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_gpg(
|
|
28
|
+
gnupghome: Path | str | None = None,
|
|
29
|
+
binary: str = GPG_BINARY,
|
|
30
|
+
*,
|
|
31
|
+
verbose: bool = False,
|
|
32
|
+
use_agent: bool = False,
|
|
33
|
+
options: list[str] | None = None
|
|
34
|
+
) -> gnupg.GPG:
|
|
35
|
+
"""
|
|
36
|
+
Construct and return a configured gnupg.GPG instance.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
gnupghome : path-like or None
|
|
41
|
+
Directory that will be used as GNUPGHOME. Created automatically if
|
|
42
|
+
it does not exist. Defaults to DEFAULT_GNUPGHOME.
|
|
43
|
+
binary : str
|
|
44
|
+
Name or full-path of the GPG binary.
|
|
45
|
+
verbose : bool
|
|
46
|
+
If True, python-gnupg will emit extra debug output.
|
|
47
|
+
use_agent : bool
|
|
48
|
+
Pass --use-agent to GPG. Usually False for scripted/non-interactive
|
|
49
|
+
workflows; True when you want the GPG agent to cache passphrases.
|
|
50
|
+
options : list[str] or None
|
|
51
|
+
Extra command-line options forwarded verbatim to GPG.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
gnupg.GPG
|
|
56
|
+
A ready-to-use GPG instance.
|
|
57
|
+
|
|
58
|
+
Raises
|
|
59
|
+
------
|
|
60
|
+
RuntimeError
|
|
61
|
+
If the GPG binary cannot be found or the keyring dir cannot be
|
|
62
|
+
created.
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
home = Path(gnupghome) if gnupghome else DEFAULT_GNUPGHOME
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
home.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
69
|
+
except OSError as exc:
|
|
70
|
+
raise RuntimeError(f"Cannot create GNUPGHOME at {home}: {exc}") from exc
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
gpg = gnupg.GPG(
|
|
74
|
+
gnupghome=str(home),
|
|
75
|
+
gpgbinary=binary,
|
|
76
|
+
verbose=verbose,
|
|
77
|
+
use_agent=use_agent,
|
|
78
|
+
options=options or []
|
|
79
|
+
)
|
|
80
|
+
except ValueError as exc:
|
|
81
|
+
raise RuntimeError(
|
|
82
|
+
f"Failed to initialize GPG (binary='{binary}'): {exc}\n"
|
|
83
|
+
"Is GPG installed and on your PATH?"
|
|
84
|
+
) from exc
|
|
85
|
+
return gpg
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def check_result(result, *, label: str = "operation") -> bool:
|
|
89
|
+
"""
|
|
90
|
+
Inspect a python-gnupg result object and print a human-readable summary.
|
|
91
|
+
|
|
92
|
+
python-gnupg result objects are not uniform - some expose '.ok', some
|
|
93
|
+
expose '.status', some expose '.returncode'. This helper normalizes the
|
|
94
|
+
differences so calling code doesn't have to.
|
|
95
|
+
|
|
96
|
+
Returns True when the operation succeeded, False otherwise.
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
ok_attr = getattr(result, "ok", None)
|
|
100
|
+
status = getattr(result, "status", "")
|
|
101
|
+
stderr = getattr(result, "stderr", "")
|
|
102
|
+
fingerprint = getattr(result, "fingerprint", None)
|
|
103
|
+
fingerprints = getattr(result, "fingerprints", None)
|
|
104
|
+
|
|
105
|
+
success = bool(ok_attr) if ok_attr is not None else (status not in ("", None))
|
|
106
|
+
|
|
107
|
+
if success:
|
|
108
|
+
print(f"[OK] {label}")
|
|
109
|
+
else:
|
|
110
|
+
print(f"[ERR] {label}")
|
|
111
|
+
|
|
112
|
+
if fingerprint:
|
|
113
|
+
print(f" fingerprint : {fingerprint}")
|
|
114
|
+
if fingerprints:
|
|
115
|
+
print(f" fingerprints : {fingerprints}")
|
|
116
|
+
if status:
|
|
117
|
+
print(f" status : {status}")
|
|
118
|
+
if stderr:
|
|
119
|
+
lines = [ln for ln in stderr.strip().splitlines() if ln]
|
|
120
|
+
tail = lines[-5:] if len(lines) > 5 else lines
|
|
121
|
+
for ln in tail:
|
|
122
|
+
print(f" stderr: : {ln}")
|
|
123
|
+
|
|
124
|
+
return success
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def inspect_gpg_version(gpg: gnupg.GPG) -> None:
|
|
128
|
+
"""Print the GPG binary version string."""
|
|
129
|
+
version = gpg.version
|
|
130
|
+
print(f"gpg binary version : {version}")
|
|
131
|
+
print(f"GNUPGHOME : {gpg.gnupghome}")
|
|
132
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "cyfer"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "A package for doing great things!"
|
|
5
|
+
authors = ["Dylan Garrett"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "^3.13"
|
|
11
|
+
python-gnupg = "^0.5.6"
|
|
12
|
+
cryptography = "^49.0.0"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["poetry-core>=1.0.0"]
|
|
17
|
+
build-backend = "poetry.core.masonry.api"
|
|
18
|
+
|
|
19
|
+
[dependency-groups]
|
|
20
|
+
dev = [
|
|
21
|
+
"ipython (>=9.15.0,<10.0.0)"
|
|
22
|
+
]
|