sleepyconvert 2.3.1__tar.gz → 2.3.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.
Files changed (33) hide show
  1. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/PKG-INFO +12 -1
  2. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/README.md +11 -0
  3. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/pyproject.toml +1 -1
  4. sleepyconvert-2.3.3/sleepyconvert/core/about.py +58 -0
  5. sleepyconvert-2.3.3/sleepyconvert/core/version.py +84 -0
  6. sleepyconvert-2.3.3/sleepyconvert/main.py +48 -0
  7. sleepyconvert-2.3.1/sleepyconvert/main.py +0 -29
  8. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/LICENSE +0 -0
  9. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/__init__.py +0 -0
  10. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/cli/__init__.py +0 -0
  11. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/cli/command_logic.py +0 -0
  12. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/core/__init__.py +0 -0
  13. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/core/config.py +0 -0
  14. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/core/logging.py +0 -0
  15. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/core/sleepy_params.py +0 -0
  16. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/__init__.py +0 -0
  17. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/csv_json.py +0 -0
  18. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/csv_parquet.py +0 -0
  19. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/csv_pkl.py +0 -0
  20. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/csv_xlsx.py +0 -0
  21. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/data_shared.py +0 -0
  22. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/doc_shared.py +0 -0
  23. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/html_md.py +0 -0
  24. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/html_pdf.py +0 -0
  25. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/image_shared.py +0 -0
  26. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/json_parquet.py +0 -0
  27. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/json_pkl.py +0 -0
  28. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/json_xlsx.py +0 -0
  29. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/md_pdf.py +0 -0
  30. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/parquet_pkl.py +0 -0
  31. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/parquet_xlsx.py +0 -0
  32. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/sleepyconvert/utils/pkl_xlsx.py +0 -0
  33. {sleepyconvert-2.3.1 → sleepyconvert-2.3.3}/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.3
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. Run `sleepyconvert about` for the project's PyPI + GitHub links.
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.
@@ -128,6 +130,15 @@ Error: Input and output extensions must belong to the same type group.
128
130
  Use `convert --help` to see the supported categories.
129
131
  ```
130
132
 
133
+ **About** — print the version and the project's public PyPI + GitHub links:
134
+
135
+ ```console
136
+ $ sleepyconvert about
137
+ sleepyconvert 2.3.1
138
+ PyPI: https://pypi.org/project/sleepyconvert/
139
+ GitHub: https://github.com/anthonybench/convert
140
+ ```
141
+
131
142
  ## Development
132
143
 
133
144
  ```sh
@@ -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. Run `sleepyconvert about` for the project's PyPI + GitHub links.
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.
@@ -84,6 +86,15 @@ Error: Input and output extensions must belong to the same type group.
84
86
  Use `convert --help` to see the supported categories.
85
87
  ```
86
88
 
89
+ **About** — print the version and the project's public PyPI + GitHub links:
90
+
91
+ ```console
92
+ $ sleepyconvert about
93
+ sleepyconvert 2.3.1
94
+ PyPI: https://pypi.org/project/sleepyconvert/
95
+ GitHub: https://github.com/anthonybench/convert
96
+ ```
97
+
87
98
  ## Development
88
99
 
89
100
  ```sh
@@ -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.3"
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,58 @@
1
+ """Public project links for the ``about`` pseudo-command.
2
+
3
+ sleepyconvert is a single-command CLI, so ``about`` is handled by a pre-scan in
4
+ the entrypoint (like ``--version``) rather than a Typer subcommand. The GitHub
5
+ URL is read from the installed package metadata (i.e. the ``[project.urls]``
6
+ entries) with a hardcoded fallback for running uninstalled from source; the PyPI
7
+ URL is derived from the distribution name.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from importlib.metadata import PackageNotFoundError, metadata
13
+
14
+ from sleepyconvert.core.version import DIST_NAME, getVersion
15
+
16
+ _GITHUB_FALLBACK = "https://github.com/anthonybench/convert"
17
+
18
+
19
+ def pypiUrl() -> str:
20
+ """Return the public PyPI project URL."""
21
+
22
+ return f"https://pypi.org/project/{DIST_NAME}/"
23
+
24
+
25
+ def githubUrl() -> str:
26
+ """Return the public GitHub URL from package metadata, or a fallback."""
27
+
28
+ try:
29
+ entries = metadata(DIST_NAME).get_all("Project-URL") or []
30
+ except PackageNotFoundError:
31
+ return _GITHUB_FALLBACK
32
+
33
+ labelled: dict[str, str] = {}
34
+ for entry in entries: # each entry looks like "Source, https://github.com/…"
35
+ label, _, url = entry.partition(",")
36
+ labelled[label.strip().lower()] = url.strip()
37
+
38
+ for key in ("source", "homepage", "repository"):
39
+ if "github.com" in labelled.get(key, ""):
40
+ return labelled[key]
41
+ for url in labelled.values():
42
+ if "github.com" in url:
43
+ return url
44
+ return _GITHUB_FALLBACK
45
+
46
+
47
+ def wantsAbout(args) -> bool:
48
+ """Return whether the first argument is the ``about`` pseudo-command."""
49
+
50
+ return bool(args) and args[0] == "about"
51
+
52
+
53
+ def printAbout() -> None:
54
+ """Print the project's version and public PyPI + GitHub links."""
55
+
56
+ print(f"{DIST_NAME} {getVersion()}")
57
+ print(f"PyPI: {pypiUrl()}")
58
+ print(f"GitHub: {githubUrl()}")
@@ -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")
@@ -0,0 +1,48 @@
1
+ """CLI entrypoint for the sleepyconvert application."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+
7
+ import typer
8
+
9
+ from sleepyconvert.cli.command_logic import runConversion
10
+ from sleepyconvert.core.about import printAbout, wantsAbout
11
+ from sleepyconvert.core.version import printVersion, wantsVersion
12
+
13
+ app = typer.Typer(
14
+ add_completion=False,
15
+ help=(
16
+ "Convert files between supported formats by passing an input and output path. "
17
+ "Pass -v/--version to print the version, or `about` for project links."
18
+ ),
19
+ )
20
+
21
+
22
+ @app.command(name="")
23
+ def main(input_path: str, output_path: str) -> None:
24
+ """Convert a file into another file of the same supported type."""
25
+
26
+ runConversion(input_path=input_path, output_path=output_path)
27
+
28
+
29
+ def run() -> None:
30
+ """Run the Typer application.
31
+
32
+ ``-v``/``--version`` and the ``about`` pseudo-command are honored before Typer
33
+ parses (sleepyconvert is a single-command CLI, so they can't be real
34
+ subcommands); when present, the conversion is skipped.
35
+ """
36
+
37
+ args = sys.argv[1:]
38
+ if wantsVersion(args):
39
+ printVersion()
40
+ return
41
+ if wantsAbout(args):
42
+ printAbout()
43
+ return
44
+ app()
45
+
46
+
47
+ if __name__ == "__main__":
48
+ run()
@@ -1,29 +0,0 @@
1
- """CLI entrypoint for the sleepyconvert application."""
2
-
3
- from __future__ import annotations
4
-
5
- import typer
6
-
7
- from sleepyconvert.cli.command_logic import runConversion
8
-
9
- app = typer.Typer(
10
- add_completion=False,
11
- help="Convert files between supported formats by passing an input and output path.",
12
- )
13
-
14
-
15
- @app.command(name="")
16
- def main(input_path: str, output_path: str) -> None:
17
- """Convert a file into another file of the same supported type."""
18
-
19
- runConversion(input_path=input_path, output_path=output_path)
20
-
21
-
22
- def run() -> None:
23
- """Run the Typer application."""
24
-
25
- app()
26
-
27
-
28
- if __name__ == "__main__":
29
- run()
File without changes