opencode-db 0.7.0__py3-none-any.whl → 0.7.2__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.
cli.py CHANGED
@@ -7,14 +7,20 @@
7
7
  - Единообразный интерфейс
8
8
  """
9
9
 
10
+ from __future__ import annotations
11
+
10
12
  import argparse
11
13
  import os
12
14
  import sys
13
15
  from typing import Any, Literal
14
16
 
15
- import commands
16
- from db import get_db
17
- from i18n import _, set_lang
17
+ from runtime import require_python
18
+
19
+ require_python()
20
+
21
+ import commands # noqa: E402
22
+ from db import get_db # noqa: E402
23
+ from i18n import _, set_lang # noqa: E402
18
24
 
19
25
 
20
26
  def build_parser() -> argparse.ArgumentParser:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opencode-db
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: OpenCode database CLI manager — browse, export, analyze, clean up sessions
5
5
  Project-URL: Homepage, https://github.com/VasilevNStas/opencode-db
6
6
  Project-URL: Source, https://github.com/VasilevNStas/opencode-db
@@ -23,6 +23,9 @@ Dynamic: license-file
23
23
 
24
24
  ```bash
25
25
  pip install opencode-db
26
+
27
+ # recommended if your system python3 is older than 3.12:
28
+ uv tool install opencode-db
26
29
  ```
27
30
 
28
31
  ## Quick start
@@ -54,6 +57,6 @@ pip install opencode-db # zero external dependencies
54
57
 
55
58
  ## Requirements
56
59
 
57
- - Python 3.12+
60
+ - Python 3.12+ — the CLI checks the interpreter at startup and exits with a clear message instead of an `ImportError` on older versions
58
61
  - [OpenCode](https://opencode.ai) (must have been run at least once)
59
62
  - macOS / Linux
@@ -1,4 +1,4 @@
1
- cli.py,sha256=NFOmI4lcoiDmJTC2c1YqmZ02IRbNdhrmIYUd6Y25aOY,2296
1
+ cli.py,sha256=H-7TFu17dqAQv_bUvQsw0Tuly57Je53WzKs6yQOjajk,2428
2
2
  cmd_costs.py,sha256=LstYavRJp-ZwwianBjRGtB8XiEKByGwMf6XwOHDHZvU,6395
3
3
  cmd_delete.py,sha256=VJyaWcxr3UVIGqkZrlXs4IOkHzySbc9dt0W6sAL5IIo,11282
4
4
  cmd_export.py,sha256=OfnNE1J9z7qbGbPqp1TXYIUBZZCEcUefkJcL1qlMdRw,6627
@@ -18,11 +18,12 @@ db.py,sha256=5NlNM9m_g2frj0oNVgJ9IIEf5oK2n6rbJqDycoVC_Mo,11914
18
18
  formatters.py,sha256=ovgtaB-gZFTCtrYl5dPWLKDUL8zG-Zl5nVHxFj2nJY4,7768
19
19
  i18n.py,sha256=7QHCc7-KcGfzA7odkesFpqfbi9XKuZ5fXZ2OTFazF68,36667
20
20
  markdown_to_ansi.py,sha256=HSr_yOZ1t1tYz5Z0Bx3yRqKzKSWxJIcuS02EKMO1WtE,6181
21
- utils.py,sha256=W5BrLO3s-ck0UFVJLAERlXHF6ck6iXQrf-wRmLxUe6c,4849
21
+ runtime.py,sha256=BbKIOdGkrcgckMvOqJgfiEpp6vDAfwO0aI-uaC4-F_M,2155
22
+ utils.py,sha256=c7RqEuxbx340RzJ1kzG14ucuf88aUzuc2gbKYb4919E,4849
22
23
  commands/__init__.py,sha256=0VZs89RtmsPYGkmgedKxPKaNtIgkMdx6HYHWHsuKCtE,1290
23
- opencode_db-0.7.0.dist-info/licenses/LICENSE,sha256=NhUr8ufTYb5u9F08J5bmDQ0xTVmCOexoq1ki_RdCqys,1210
24
- opencode_db-0.7.0.dist-info/METADATA,sha256=yarIoKVOaRcfp_Xk0yNBrJjur-CAbxKWwUfmiEfccmc,2302
25
- opencode_db-0.7.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
26
- opencode_db-0.7.0.dist-info/entry_points.txt,sha256=dMHc-RWkGEu0mTNvHHThSEKQdGbCdwdKUCO-cLF7TCw,41
27
- opencode_db-0.7.0.dist-info/top_level.txt,sha256=rfyZ4RpmxOeSt4zcQ_ycvFMbBJpt1_WPuBFSnoRTSG4,204
28
- opencode_db-0.7.0.dist-info/RECORD,,
24
+ opencode_db-0.7.2.dist-info/licenses/LICENSE,sha256=NhUr8ufTYb5u9F08J5bmDQ0xTVmCOexoq1ki_RdCqys,1210
25
+ opencode_db-0.7.2.dist-info/METADATA,sha256=xB704HtWzrLTwEOtBrgPt_9BvP5Pzie1pXYpf1L5azk,2511
26
+ opencode_db-0.7.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
+ opencode_db-0.7.2.dist-info/entry_points.txt,sha256=dMHc-RWkGEu0mTNvHHThSEKQdGbCdwdKUCO-cLF7TCw,41
28
+ opencode_db-0.7.2.dist-info/top_level.txt,sha256=CnAP9fA7TDBA6mjuh2AWR2bo4ceTfTpxwLn-pe0Kcj4,212
29
+ opencode_db-0.7.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (84.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -19,4 +19,5 @@ db
19
19
  formatters
20
20
  i18n
21
21
  markdown_to_ansi
22
+ runtime
22
23
  utils
runtime.py ADDED
@@ -0,0 +1,55 @@
1
+ """Проверка минимальной версии Python.
2
+
3
+ Модуль намеренно написан без синтаксиса новее Python 3.8, чтобы его можно
4
+ было импортировать до проверки версии и показать понятную ошибку вместо
5
+ ImportError/SyntaxError.
6
+ """
7
+
8
+ import sys
9
+
10
+ MIN_PYTHON = (3, 12)
11
+ REQUIRED_VERSION = "3.12"
12
+
13
+
14
+ def format_version_error(version_info=None, executable=None) -> str:
15
+ """Возвращает текст ошибки для неподдерживаемой версии Python."""
16
+ info = version_info or sys.version_info
17
+ exe = executable or sys.executable
18
+ current = f"{info[0]}.{info[1]}.{info[2]}"
19
+
20
+ return (
21
+ f"opencode-db requires Python {REQUIRED_VERSION}+.\n"
22
+ f"opencode-db требует Python {REQUIRED_VERSION}+.\n"
23
+ "\n"
24
+ f"Current interpreter: Python {current} ({exe})\n"
25
+ f"Текущий интерпретатор: Python {current} ({exe})\n"
26
+ "\n"
27
+ "How to fix / Как исправить:\n"
28
+ " uv python install 3.13\n"
29
+ " uv venv --python 3.13\n"
30
+ " source .venv/bin/activate\n"
31
+ " pip install -e .\n"
32
+ "\n"
33
+ "Or run with uv / Или запуск через uv:\n"
34
+ " uv run --python 3.13 opencode-db --help\n"
35
+ " uv tool install --editable . && opencode-db --help\n"
36
+ "\n"
37
+ "After changing the interpreter, rerun install.sh to regenerate\n"
38
+ "the ~/.local/bin/opencode-db launcher."
39
+ )
40
+
41
+
42
+ def check_python_version(version_info=None):
43
+ """Возвращает None, если версия подходит, иначе текст ошибки."""
44
+ info = version_info or sys.version_info
45
+ if tuple(info[:2]) >= MIN_PYTHON:
46
+ return None
47
+ return format_version_error(info)
48
+
49
+
50
+ def require_python() -> None:
51
+ """Завершает процесс с понятной ошибкой, если Python слишком старый."""
52
+ message = check_python_version()
53
+ if message:
54
+ print(message, file=sys.stderr)
55
+ raise SystemExit(1)
utils.py CHANGED
@@ -50,7 +50,7 @@ def parse_date(date_str: str) -> datetime | None:
50
50
  return None
51
51
 
52
52
 
53
- def parse_time_spec(spec) -> None | datetime:
53
+ def parse_time_spec(spec) -> datetime | None:
54
54
  """Парсит спецификацию времени ('30d', '6m', '1y') в timedelta."""
55
55
  if not spec or not isinstance(spec, str):
56
56
  return None