sleepyconvert 2.3.1__tar.gz → 2.3.2__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.
Files changed (31) hide show
  1. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/PKG-INFO +3 -1
  2. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/README.md +2 -0
  3. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/pyproject.toml +1 -1
  4. sleepyconvert-2.3.2/sleepyconvert/core/version.py +84 -0
  5. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/main.py +15 -2
  6. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/LICENSE +0 -0
  7. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/__init__.py +0 -0
  8. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/cli/__init__.py +0 -0
  9. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/cli/command_logic.py +0 -0
  10. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/core/__init__.py +0 -0
  11. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/core/config.py +0 -0
  12. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/core/logging.py +0 -0
  13. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/core/sleepy_params.py +0 -0
  14. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/__init__.py +0 -0
  15. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/csv_json.py +0 -0
  16. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/csv_parquet.py +0 -0
  17. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/csv_pkl.py +0 -0
  18. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/csv_xlsx.py +0 -0
  19. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/data_shared.py +0 -0
  20. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/doc_shared.py +0 -0
  21. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/html_md.py +0 -0
  22. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/html_pdf.py +0 -0
  23. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/image_shared.py +0 -0
  24. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/json_parquet.py +0 -0
  25. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/json_pkl.py +0 -0
  26. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/json_xlsx.py +0 -0
  27. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/md_pdf.py +0 -0
  28. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/parquet_pkl.py +0 -0
  29. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/parquet_xlsx.py +0 -0
  30. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/pkl_xlsx.py +0 -0
  31. {sleepyconvert-2.3.1 → sleepyconvert-2.3.2}/sleepyconvert/utils/png_jpg.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sleepyconvert
3
- Version: 2.3.1
3
+ Version: 2.3.2
4
4
  Summary: Convert data files, images, and documents between formats from a single terse CLI.
5
5
  License-Expression: GPL-3.0-or-later
6
6
  License-File: LICENSE
@@ -62,6 +62,8 @@ Description-Content-Type: text/markdown
62
62
  uv tool install sleepyconvert # or: pipx install sleepyconvert
63
63
  ```
64
64
 
65
+ > `-v` / `--version` prints the version and best-effort checks PyPI for a newer release — it works even when placed alongside the paths.
66
+
65
67
  ## Configure
66
68
 
67
69
  `sleepyconvert` is a _sleepy util_ and reads its settings from the shared `~/sleepyconfig/params.yml`, using the `convert_` key prefix. If the file is absent it writes **only its own section** (below) and says so; if a value it needs is missing it prints this snippet and asks you to verify your config.
@@ -18,6 +18,8 @@
18
18
  uv tool install sleepyconvert # or: pipx install sleepyconvert
19
19
  ```
20
20
 
21
+ > `-v` / `--version` prints the version and best-effort checks PyPI for a newer release — it works even when placed alongside the paths.
22
+
21
23
  ## Configure
22
24
 
23
25
  `sleepyconvert` is a _sleepy util_ and reads its settings from the shared `~/sleepyconfig/params.yml`, using the `convert_` key prefix. If the file is absent it writes **only its own section** (below) and says so; if a value it needs is missing it prints this snippet and asks you to verify your config.
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "sleepyconvert"
7
- version = "2.3.1"
7
+ version = "2.3.2"
8
8
  description = "Convert data files, images, and documents between formats from a single terse CLI."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -0,0 +1,84 @@
1
+ """Version reporting and a best-effort PyPI update check.
2
+
3
+ The ``-v``/``--version`` flag is handled by a pre-scan of ``sys.argv`` in the CLI
4
+ entrypoint (see ``run``), so it works even when it appears alongside the
5
+ input/output paths (e.g. ``sleepyconvert a.csv b.parquet --version``) — the rest
6
+ of the command is ignored. The update check is best-effort and never fails the CLI.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import urllib.request
13
+ from importlib.metadata import PackageNotFoundError, version
14
+ from typing import Callable, Optional, Sequence
15
+
16
+ DIST_NAME = "sleepyconvert"
17
+ _PYPI_JSON_URL = f"https://pypi.org/pypi/{DIST_NAME}/json"
18
+ _UPDATE_CHECK_TIMEOUT_SECONDS = 2.0
19
+
20
+
21
+ def getVersion() -> str:
22
+ """Return the installed distribution version, or ``"unknown"`` if unavailable."""
23
+
24
+ try:
25
+ return version(DIST_NAME)
26
+ except PackageNotFoundError:
27
+ return "unknown"
28
+
29
+
30
+ def latestVersion() -> Optional[str]:
31
+ """Best-effort fetch of the latest version on PyPI; ``None`` on any failure."""
32
+
33
+ try:
34
+ with urllib.request.urlopen(
35
+ _PYPI_JSON_URL, timeout=_UPDATE_CHECK_TIMEOUT_SECONDS
36
+ ) as response:
37
+ payload = json.load(response)
38
+ return str(payload["info"]["version"])
39
+ except Exception: # noqa: BLE001 - the check is best-effort; never fail the CLI
40
+ return None
41
+
42
+
43
+ def _asTuple(value: str) -> tuple[int, ...]:
44
+ return tuple(int(part) for part in value.split(".") if part.isdigit())
45
+
46
+
47
+ def isNewer(candidate: str, current: str) -> bool:
48
+ """Return whether ``candidate`` is a newer release than ``current``."""
49
+
50
+ candidate_parts, current_parts = _asTuple(candidate), _asTuple(current)
51
+ if candidate_parts and current_parts:
52
+ return candidate_parts > current_parts
53
+ return candidate != current # fall back to inequality if unparseable
54
+
55
+
56
+ def wantsVersion(args: Sequence[str]) -> bool:
57
+ """Return whether ``-v``/``--version`` appears anywhere in the given args."""
58
+
59
+ return any(arg in ("-v", "--version") for arg in args)
60
+
61
+
62
+ def printVersion(fetch_latest: Callable[[], Optional[str]] = latestVersion) -> None:
63
+ """Print the current version and, best-effort, whether a newer one exists.
64
+
65
+ Args:
66
+ fetch_latest: Callable returning the latest published version (or ``None``
67
+ when it can't be determined). Injectable for tests.
68
+
69
+ Returns:
70
+ None.
71
+ """
72
+
73
+ current = getVersion()
74
+ print(f"{DIST_NAME} {current}")
75
+
76
+ latest = fetch_latest()
77
+ if latest is None:
78
+ return # offline / lookup failed — stay quiet
79
+ if current == "unknown":
80
+ print(f"latest on PyPI: {latest}")
81
+ elif isNewer(latest, current):
82
+ print(f"⬆️ a newer version is available: {latest} (upgrade: uv tool upgrade {DIST_NAME})")
83
+ else:
84
+ print("✅ you're on the latest version")
@@ -2,13 +2,19 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import sys
6
+
5
7
  import typer
6
8
 
7
9
  from sleepyconvert.cli.command_logic import runConversion
10
+ from sleepyconvert.core.version import printVersion, wantsVersion
8
11
 
9
12
  app = typer.Typer(
10
13
  add_completion=False,
11
- help="Convert files between supported formats by passing an input and output path.",
14
+ help=(
15
+ "Convert files between supported formats by passing an input and output path. "
16
+ "Pass -v/--version to print the version."
17
+ ),
12
18
  )
13
19
 
14
20
 
@@ -20,8 +26,15 @@ def main(input_path: str, output_path: str) -> None:
20
26
 
21
27
 
22
28
  def run() -> None:
23
- """Run the Typer application."""
29
+ """Run the Typer application.
30
+
31
+ ``-v``/``--version`` is honored before Typer parses, so it works even when it
32
+ appears alongside the paths; the conversion is skipped.
33
+ """
24
34
 
35
+ if wantsVersion(sys.argv[1:]):
36
+ printVersion()
37
+ return
25
38
  app()
26
39
 
27
40
 
File without changes