zora-cli 0.1.2__tar.gz → 0.1.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zora-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Cryptographically secure generator of random keys with tons of options and customizations.
5
5
  Author: zscopuv
6
6
  License: ZORA SOURCE-AVAILABLE LICENSE
@@ -224,10 +224,11 @@ Requires-Python: >=3.9
224
224
  Description-Content-Type: text/markdown
225
225
  License-File: LICENSE
226
226
  Requires-Dist: colorama==0.4.6
227
+ Requires-Dist: packaging>=24.0
227
228
  Dynamic: license-file
228
229
 
229
230
  # ![Logo](zora.jpg)
230
- > **Early release (`v0.1.2`)**
231
+ > **Early release (`v0.1.3`)**
231
232
 
232
233
  Zora generates random keys using Python's cryptographically secure
233
234
  `secrets` module by default. It supports customizable character sets,
@@ -1,5 +1,5 @@
1
1
  # ![Logo](zora.jpg)
2
- > **Early release (`v0.1.2`)**
2
+ > **Early release (`v0.1.3`)**
3
3
 
4
4
  Zora generates random keys using Python's cryptographically secure
5
5
  `secrets` module by default. It supports customizable character sets,
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "zora-cli"
7
- version = "0.1.2"
7
+ version = "0.1.3"
8
8
  description = "Cryptographically secure generator of random keys with tons of options and customizations."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -13,7 +13,8 @@ authors = [
13
13
  { name = "zscopuv" }
14
14
  ]
15
15
  dependencies = [
16
- "colorama==0.4.6"
16
+ "colorama==0.4.6",
17
+ "packaging>=24.0"
17
18
  ]
18
19
 
19
20
  [project.scripts]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3"
@@ -3,6 +3,8 @@ import time
3
3
  import string
4
4
  import argparse
5
5
  import random, secrets
6
+ from . import __version__
7
+ from .update import check_for_update
6
8
  from colorama import Fore, init; init(autoreset=True);
7
9
 
8
10
  def positive_int(value):
@@ -34,7 +36,22 @@ class Zora:
34
36
  self.output()
35
37
  self.show_timer()
36
38
  self.show_entropy()
39
+ if not self.args.quiet:
40
+ self.check_update()
41
+
42
+ def check_update(self):
43
+ latest = check_for_update()
37
44
 
45
+ if latest:
46
+ print(
47
+ f"\n{Fore.WHITE}"
48
+ f"A new version of zora-cli is available: "
49
+ f"{Fore.RED}{__version__} {Fore.WHITE}→ {Fore.GREEN}{latest}"
50
+ )
51
+ print(
52
+ f"{Fore.WHITE}"
53
+ f"Run: {Fore.LIGHTYELLOW_EX}pip install --upgrade zora-cli\n"
54
+ )
38
55
 
39
56
  def build_charset(self):
40
57
  value = self.args.charset
@@ -91,7 +108,7 @@ class Zora:
91
108
  sc("-q", "--quiet", action="store_true", help="Suppress non-essential output")
92
109
 
93
110
 
94
- sc("--charset", default="@letters", help="Character set to use (see --charset-list)")
111
+ sc("-x", "--charset", default="@letters", help="Character set to use (see --charset-list)")
95
112
 
96
113
  self.args = self.parser.parse_args()
97
114
 
@@ -0,0 +1,72 @@
1
+ import json
2
+ import time
3
+ import urllib.request
4
+ from pathlib import Path
5
+
6
+ from packaging.version import Version
7
+
8
+ from . import __version__
9
+
10
+
11
+ PYPI_URL = "https://pypi.org/pypi/zora-cli/json"
12
+
13
+ CHECK_INTERVAL = 60 * 60 * 24 # 24 hours
14
+
15
+
16
+ def _cache_file():
17
+ return Path.home() / ".cache" / "zora" / "update.json"
18
+
19
+
20
+ def get_latest_version():
21
+ try:
22
+ request = urllib.request.Request(
23
+ PYPI_URL,
24
+ headers={
25
+ "User-Agent": f"zora-cli/{__version__}"
26
+ },
27
+ )
28
+
29
+ with urllib.request.urlopen(request, timeout=2) as response:
30
+ data = json.load(response)
31
+
32
+ return data["info"]["version"]
33
+
34
+ except Exception:
35
+ return None
36
+
37
+
38
+ def check_for_update():
39
+ cache = _cache_file()
40
+
41
+ try:
42
+ if cache.exists():
43
+ data = json.loads(cache.read_text())
44
+
45
+ if time.time() - data["checked"] < CHECK_INTERVAL:
46
+ latest = data.get("latest")
47
+
48
+ if latest and Version(latest) > Version(__version__):
49
+ return latest
50
+
51
+ return None
52
+ except Exception:
53
+ pass
54
+
55
+ latest = get_latest_version()
56
+
57
+ try:
58
+ cache.parent.mkdir(parents=True, exist_ok=True)
59
+
60
+ cache.write_text(
61
+ json.dumps({
62
+ "checked": time.time(),
63
+ "latest": latest,
64
+ })
65
+ )
66
+ except Exception:
67
+ pass
68
+
69
+ if latest and Version(latest) > Version(__version__):
70
+ return latest
71
+
72
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zora-cli
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Cryptographically secure generator of random keys with tons of options and customizations.
5
5
  Author: zscopuv
6
6
  License: ZORA SOURCE-AVAILABLE LICENSE
@@ -224,10 +224,11 @@ Requires-Python: >=3.9
224
224
  Description-Content-Type: text/markdown
225
225
  License-File: LICENSE
226
226
  Requires-Dist: colorama==0.4.6
227
+ Requires-Dist: packaging>=24.0
227
228
  Dynamic: license-file
228
229
 
229
230
  # ![Logo](zora.jpg)
230
- > **Early release (`v0.1.2`)**
231
+ > **Early release (`v0.1.3`)**
231
232
 
232
233
  Zora generates random keys using Python's cryptographically secure
233
234
  `secrets` module by default. It supports customizable character sets,
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  zora/__init__.py
5
5
  zora/cli.py
6
+ zora/update.py
6
7
  zora_cli.egg-info/PKG-INFO
7
8
  zora_cli.egg-info/SOURCES.txt
8
9
  zora_cli.egg-info/dependency_links.txt
@@ -1 +1,2 @@
1
1
  colorama==0.4.6
2
+ packaging>=24.0
@@ -1 +0,0 @@
1
- __version__ = "0.1.2"
File without changes
File without changes