pollyweb-cli 0.1.dev3__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.
@@ -0,0 +1 @@
1
+ """pollyweb CLI package."""
pollyweb_cli/cli.py ADDED
@@ -0,0 +1,84 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ from pollyweb import KeyPair
8
+ from cryptography.hazmat.primitives.serialization import (
9
+ Encoding,
10
+ NoEncryption,
11
+ PrivateFormat,
12
+ PublicFormat,
13
+ )
14
+
15
+
16
+ CONFIG_DIR = Path.home() / ".pollyweb"
17
+ PRIVATE_KEY_PATH = CONFIG_DIR / "private.pem"
18
+ PUBLIC_KEY_PATH = CONFIG_DIR / "public.pem"
19
+
20
+
21
+ def build_parser() -> argparse.ArgumentParser:
22
+ parser = argparse.ArgumentParser(
23
+ prog="pw",
24
+ description="PollyWeb command line wallet.",
25
+ )
26
+ subparsers = parser.add_subparsers(dest="command")
27
+
28
+ config_parser = subparsers.add_parser(
29
+ "config",
30
+ help="Generate a PollyWeb key pair in ~/.pollyweb.",
31
+ )
32
+ config_parser.add_argument(
33
+ "--force",
34
+ action="store_true",
35
+ help="Overwrite an existing key pair.",
36
+ )
37
+
38
+ return parser
39
+
40
+
41
+ def cmd_config(force: bool) -> int:
42
+ if not force and (PRIVATE_KEY_PATH.exists() or PUBLIC_KEY_PATH.exists()):
43
+ print(
44
+ "Key files already exist. Re-run with --force to overwrite them.",
45
+ file=sys.stderr,
46
+ )
47
+ return 1
48
+
49
+ CONFIG_DIR.mkdir(mode=0o700, parents=True, exist_ok=True)
50
+
51
+ key_pair = KeyPair()
52
+ private_pem = key_pair.PrivateKey.private_bytes(
53
+ encoding=Encoding.PEM,
54
+ format=PrivateFormat.PKCS8,
55
+ encryption_algorithm=NoEncryption(),
56
+ )
57
+ public_pem = key_pair.PublicKey.public_bytes(
58
+ encoding=Encoding.PEM,
59
+ format=PublicFormat.SubjectPublicKeyInfo,
60
+ )
61
+
62
+ PRIVATE_KEY_PATH.write_bytes(private_pem)
63
+ PUBLIC_KEY_PATH.write_bytes(public_pem)
64
+ PRIVATE_KEY_PATH.chmod(0o600)
65
+ PUBLIC_KEY_PATH.chmod(0o644)
66
+
67
+ print(f"Created {PRIVATE_KEY_PATH}")
68
+ print(f"Created {PUBLIC_KEY_PATH}")
69
+ return 0
70
+
71
+
72
+ def main(argv: list[str] | None = None) -> int:
73
+ parser = build_parser()
74
+ args = parser.parse_args(argv)
75
+
76
+ if args.command == "config":
77
+ return cmd_config(force=args.force)
78
+
79
+ parser.print_help()
80
+ return 0
81
+
82
+
83
+ if __name__ == "__main__":
84
+ raise SystemExit(main())
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: pollyweb-cli
3
+ Version: 0.1.dev3
4
+ Summary: Command line wallet tooling built on the pollyweb library.
5
+ Project-URL: Homepage, https://pypi.org/project/pollyweb-cli/
6
+ Project-URL: Source, https://github.com/jorgemf/wallet-cli
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: pollyweb==1.0.4
10
+ Provides-Extra: dev
11
+ Requires-Dist: build>=1.2; extra == "dev"
12
+ Requires-Dist: pytest>=8.0; extra == "dev"
13
+
14
+ # pollyweb-cli
15
+
16
+ Command line wallet tooling built on top of the `pollyweb` Python package.
@@ -0,0 +1,7 @@
1
+ pollyweb_cli/__init__.py,sha256=Pxe4u5sd5ML_0GbEKJz5yOtCzoVkJSTO8t3BaRpbZYA,28
2
+ pollyweb_cli/cli.py,sha256=cuj7C5G-HVN7WlryWWUh7Tn84MiEwPS2G6EIstKTKNY,2084
3
+ pollyweb_cli-0.1.dev3.dist-info/METADATA,sha256=wL8mh53PBEN3-45nplVl8Q6_5SNbAYDeXnj1PGqiMx8,540
4
+ pollyweb_cli-0.1.dev3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ pollyweb_cli-0.1.dev3.dist-info/entry_points.txt,sha256=j0poUF2Aj42U_vEvrNPGQ3CqgFSoH-zV3aG24KrhpAU,45
6
+ pollyweb_cli-0.1.dev3.dist-info/top_level.txt,sha256=bSAerCOzZo-Gi4DNG08ATGgZxaTBNr4Rfl0fQdzxvVM,13
7
+ pollyweb_cli-0.1.dev3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pw = pollyweb_cli.cli:main
@@ -0,0 +1 @@
1
+ pollyweb_cli