python-lucide 0.5.13__tar.gz → 0.5.15__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.
- {python_lucide-0.5.13 → python_lucide-0.5.15}/Makefile +2 -6
- {python_lucide-0.5.13 → python_lucide-0.5.15}/PKG-INFO +5 -26
- {python_lucide-0.5.13 → python_lucide-0.5.15}/README.md +2 -24
- {python_lucide-0.5.13 → python_lucide-0.5.15}/pyproject.toml +7 -17
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/__init__.py +6 -1
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/build_clusters.py +7 -7
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/build_search.py +9 -5
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/cli.py +8 -20
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/config.py +3 -2
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/core.py +24 -7
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/data/gemini-icon-descriptions.jsonl +104 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/data/lucide-icon-clusters.json +5686 -5191
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/data/lucide-icons.sql +3274 -520
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/db.py +8 -4
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/dev_utils.py +3 -3
- python_lucide-0.5.15/src/lucide/py.typed +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/search.py +55 -39
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/build_clusters_test.py +46 -1
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/build_search_test.py +3 -3
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/cli_test.py +11 -2
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/conftest.py +1 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/core_test.py +71 -9
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/search_test.py +52 -16
- {python_lucide-0.5.13 → python_lucide-0.5.15}/.gitignore +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/LICENSE +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/build_support.py +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/hatch_build.py +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/src/lucide/data/__init__.py +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/__init__.py +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/tests/db_source_test.py +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/App.svelte +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/app.css +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/components/DetailPanel.svelte +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/lib/clusters.ts +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/lib/embeddings.ts +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/lib/model-loader.ts +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/lib/types.ts +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/main.ts +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/pages/ExplorePage.svelte +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/pages/SearchPage.svelte +0 -0
- {python_lucide-0.5.13 → python_lucide-0.5.15}/web/src/vite-env.d.ts +0 -0
|
@@ -48,15 +48,11 @@ help:
|
|
|
48
48
|
@echo " nuke A more thorough clean: runs 'clean', 'uv cache clean', and removes $(VENV_DIR)."
|
|
49
49
|
@echo ""
|
|
50
50
|
|
|
51
|
-
env:
|
|
51
|
+
env:
|
|
52
52
|
@echo "Installing/updating development dependencies into $(VENV_DIR)..."
|
|
53
|
-
$(UV_CMD)
|
|
53
|
+
$(UV_CMD) sync --dev
|
|
54
54
|
@echo "Development environment ready in $(VENV_DIR)/."
|
|
55
55
|
|
|
56
|
-
$(VENV_DIR)/pyvenv.cfg:
|
|
57
|
-
@echo "Creating virtual environment in $(VENV_DIR)/ using $(UV_CMD)..."
|
|
58
|
-
$(UV_CMD) venv $(VENV_DIR)
|
|
59
|
-
|
|
60
56
|
lucide-db:
|
|
61
57
|
@echo "Building Lucide icon database with tag $(TAG) into $(DB_OUTPUT_PATH)..."
|
|
62
58
|
@mkdir -p src/lucide/data # Ensure data directory exists
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-lucide
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.15
|
|
4
4
|
Summary: A Python package for working with Lucide icons
|
|
5
5
|
Project-URL: Bug Tracker, https://github.com/mmacpherson/python-lucide/issues
|
|
6
6
|
Project-URL: Homepage, https://github.com/mmacpherson/python-lucide
|
|
@@ -17,11 +17,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
22
|
Requires-Python: >=3.11
|
|
22
23
|
Provides-Extra: search
|
|
23
24
|
Requires-Dist: cairosvg>=2.7.0; extra == 'search'
|
|
24
|
-
Requires-Dist:
|
|
25
|
+
Requires-Dist: candle-embed>=0.1.0; extra == 'search'
|
|
25
26
|
Description-Content-Type: text/markdown
|
|
26
27
|
|
|
27
28
|
# python-lucide
|
|
@@ -56,20 +57,8 @@ pip install python-lucide
|
|
|
56
57
|
```
|
|
57
58
|
This installs the package with a pre-built database of all Lucide icons, ready to use immediately.
|
|
58
59
|
|
|
59
|
-
Python 3.11–3.
|
|
60
|
-
|
|
61
|
-
a dedicated CI job, but semantic search is currently unsupported because ONNX
|
|
62
|
-
Runtime does not yet provide compatible wheels. Core installation remains
|
|
63
|
-
available on 3.15; full support will be advertised once search is validated too.
|
|
64
|
-
Use Python 3.11–3.14 for search and full development tooling. HDBSCAN and UMAP's
|
|
65
|
-
dependencies affect cluster generation during development, not ordinary searches.
|
|
66
|
-
|
|
67
|
-
To run the core tests on Python 3.15 from a source checkout:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
uv sync --python 3.15 --no-dev --group test-core
|
|
71
|
-
uv run --no-sync python -m pytest tests/core_test.py tests/db_source_test.py
|
|
72
|
-
```
|
|
60
|
+
Python 3.11–3.15 are supported, including semantic search (`python-lucide[search]`)
|
|
61
|
+
and full development/clustering tooling.
|
|
73
62
|
|
|
74
63
|
## Quick Start
|
|
75
64
|
```python
|
|
@@ -165,16 +154,6 @@ pip install "python-lucide[search]"
|
|
|
165
154
|
lucide search "celebrate a big achievement"
|
|
166
155
|
```
|
|
167
156
|
|
|
168
|
-
If your application uses Python 3.15, run the search CLI separately under Python
|
|
169
|
-
3.14, or use the [browser search](https://mmacpherson.github.io/python-lucide/):
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
uvx --python 3.14 --from "python-lucide[search]" lucide search "payment"
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
This runs the CLI in a separate environment; calling `search_icons()` from your
|
|
176
|
-
application still requires a supported Python version with the search extra.
|
|
177
|
-
|
|
178
157
|
<img src="https://raw.githubusercontent.com/mmacpherson/python-lucide/main/.github/images/search-cli.png" width="360" alt="Terminal output of lucide search: each result icon renders inline next to its name and match score">
|
|
179
158
|
|
|
180
159
|
In terminals supporting the Kitty graphics protocol (kitty, Ghostty,
|
|
@@ -30,20 +30,8 @@ pip install python-lucide
|
|
|
30
30
|
```
|
|
31
31
|
This installs the package with a pre-built database of all Lucide icons, ready to use immediately.
|
|
32
32
|
|
|
33
|
-
Python 3.11–3.
|
|
34
|
-
|
|
35
|
-
a dedicated CI job, but semantic search is currently unsupported because ONNX
|
|
36
|
-
Runtime does not yet provide compatible wheels. Core installation remains
|
|
37
|
-
available on 3.15; full support will be advertised once search is validated too.
|
|
38
|
-
Use Python 3.11–3.14 for search and full development tooling. HDBSCAN and UMAP's
|
|
39
|
-
dependencies affect cluster generation during development, not ordinary searches.
|
|
40
|
-
|
|
41
|
-
To run the core tests on Python 3.15 from a source checkout:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
uv sync --python 3.15 --no-dev --group test-core
|
|
45
|
-
uv run --no-sync python -m pytest tests/core_test.py tests/db_source_test.py
|
|
46
|
-
```
|
|
33
|
+
Python 3.11–3.15 are supported, including semantic search (`python-lucide[search]`)
|
|
34
|
+
and full development/clustering tooling.
|
|
47
35
|
|
|
48
36
|
## Quick Start
|
|
49
37
|
```python
|
|
@@ -139,16 +127,6 @@ pip install "python-lucide[search]"
|
|
|
139
127
|
lucide search "celebrate a big achievement"
|
|
140
128
|
```
|
|
141
129
|
|
|
142
|
-
If your application uses Python 3.15, run the search CLI separately under Python
|
|
143
|
-
3.14, or use the [browser search](https://mmacpherson.github.io/python-lucide/):
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
uvx --python 3.14 --from "python-lucide[search]" lucide search "payment"
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
This runs the CLI in a separate environment; calling `search_icons()` from your
|
|
150
|
-
application still requires a supported Python version with the search extra.
|
|
151
|
-
|
|
152
130
|
<img src="https://raw.githubusercontent.com/mmacpherson/python-lucide/main/.github/images/search-cli.png" width="360" alt="Terminal output of lucide search: each result icon renders inline next to its name and match score">
|
|
153
131
|
|
|
154
132
|
In terminals supporting the Kitty graphics protocol (kitty, Ghostty,
|
|
@@ -6,22 +6,16 @@ requires = ["hatchling>=1.27,<2"]
|
|
|
6
6
|
dev = [
|
|
7
7
|
{ include-group = "test-core" },
|
|
8
8
|
"cairosvg>=2.7.0",
|
|
9
|
-
"
|
|
10
|
-
"hdbscan>=0.8.0",
|
|
9
|
+
"candle-embed>=0.1.0",
|
|
11
10
|
"mypy-extensions>=1.0.0",
|
|
12
11
|
"mypy>=1.0.0",
|
|
13
|
-
# Floor keeps the resolver off ancient numba/llvmlite, which fail to build
|
|
14
|
-
# from source when numpy resolves above modern numba's cap.
|
|
15
|
-
"numba>=0.60",
|
|
16
12
|
"plotly>=5.0.0",
|
|
17
13
|
"pre-commit>=3.0.0",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"pydantic-ai-slim[google]>=1.0.0,<2",
|
|
14
|
+
"pydantic-ai-slim[google]>=1.0.0",
|
|
15
|
+
"raso>=0.2.0",
|
|
21
16
|
"ruff>=0.1.0",
|
|
22
17
|
"types-setuptools>=80.9.0.20250529",
|
|
23
|
-
"typing-extensions>=4.1.0"
|
|
24
|
-
"umap-learn>=0.5.0"
|
|
18
|
+
"typing-extensions>=4.1.0"
|
|
25
19
|
]
|
|
26
20
|
test-core = ["pytest-cov>=4.0.0", "pytest>=7.0.0"]
|
|
27
21
|
|
|
@@ -36,6 +30,7 @@ classifiers = [
|
|
|
36
30
|
"Programming Language :: Python :: 3.12",
|
|
37
31
|
"Programming Language :: Python :: 3.13",
|
|
38
32
|
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Programming Language :: Python :: 3.15",
|
|
39
34
|
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
40
35
|
]
|
|
41
36
|
dependencies = []
|
|
@@ -45,10 +40,10 @@ license = { text = "MIT" }
|
|
|
45
40
|
name = "python-lucide"
|
|
46
41
|
readme = "README.md"
|
|
47
42
|
requires-python = ">=3.11"
|
|
48
|
-
version = "0.5.
|
|
43
|
+
version = "0.5.15"
|
|
49
44
|
|
|
50
45
|
[project.optional-dependencies]
|
|
51
|
-
search = ["cairosvg>=2.7.0", "
|
|
46
|
+
search = ["cairosvg>=2.7.0", "candle-embed>=0.1.0"]
|
|
52
47
|
|
|
53
48
|
[project.scripts]
|
|
54
49
|
check-lucide-version = "lucide.dev_utils:print_version_status"
|
|
@@ -160,8 +155,3 @@ convention = "google"
|
|
|
160
155
|
[tool.uv]
|
|
161
156
|
# SQL edits must invalidate uv's cached editable build too.
|
|
162
157
|
cache-keys = [{ file = "pyproject.toml" }, { file = "hatch_build.py" }, { file = "build_support.py" }, { file = "src/lucide/data/lucide-icons.sql" }]
|
|
163
|
-
# fastembed (search extra) caps pillow below 13, but every pillow before 13.0.0
|
|
164
|
-
# has critical advisories (GHSA-8g5g-8vmr-9782, GHSA-332p-7hrc-92wf,
|
|
165
|
-
# GHSA-w889-685w-c8fh). Override it for development and CI; this doesn't change
|
|
166
|
-
# what users install. Remove once fastembed allows pillow 13.
|
|
167
|
-
override-dependencies = ["pillow>=13"]
|
|
@@ -4,7 +4,12 @@ This package provides utilities for creating, accessing, and using Lucide
|
|
|
4
4
|
icons from a SQLite database.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
__version__ = version("python-lucide")
|
|
11
|
+
except PackageNotFoundError: # pragma: no cover -- uninstalled source checkout
|
|
12
|
+
__version__ = "0.0.0+unknown"
|
|
8
13
|
|
|
9
14
|
from .core import create_placeholder_svg, get_icon_list, lucide_icon
|
|
10
15
|
from .db import get_db_connection, get_default_db_path
|
|
@@ -4,8 +4,8 @@ Uses UMAP for dimensionality reduction, HDBSCAN for density-based
|
|
|
4
4
|
clustering, and Gemini Flash to generate evocative theme names from
|
|
5
5
|
the icon names in each cluster.
|
|
6
6
|
|
|
7
|
-
Build-time only — requires ``
|
|
8
|
-
|
|
7
|
+
Build-time only — requires ``raso`` and ``plotly`` (both in the dev
|
|
8
|
+
dependency group).
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
import json
|
|
@@ -20,6 +20,7 @@ from pydantic_ai import Agent
|
|
|
20
20
|
from pydantic_ai.models import Model
|
|
21
21
|
|
|
22
22
|
from .config import DEFAULT_SEARCH_MODEL_ID
|
|
23
|
+
from .db import sqlite_ro_uri
|
|
23
24
|
|
|
24
25
|
logger = logging.getLogger(__name__)
|
|
25
26
|
|
|
@@ -92,10 +93,9 @@ def discover_clusters(
|
|
|
92
93
|
Dict with keys: clusters, coords, descriptions.
|
|
93
94
|
"""
|
|
94
95
|
import numpy as np # noqa: PLC0415
|
|
95
|
-
import
|
|
96
|
-
from hdbscan import HDBSCAN # noqa: PLC0415
|
|
96
|
+
from raso import HDBSCAN, UMAP # noqa: PLC0415
|
|
97
97
|
|
|
98
|
-
conn = sqlite3.connect(
|
|
98
|
+
conn = sqlite3.connect(sqlite_ro_uri(search_db_path), uri=True)
|
|
99
99
|
rows = conn.execute(
|
|
100
100
|
"SELECT e.name, e.embedding, d.description "
|
|
101
101
|
"FROM icon_embeddings e "
|
|
@@ -112,7 +112,7 @@ def discover_clusters(
|
|
|
112
112
|
logger.info("Loaded %d embeddings (%dd)", len(names), matrix.shape[1])
|
|
113
113
|
|
|
114
114
|
logger.info("Running UMAP (2D projection)...")
|
|
115
|
-
reducer =
|
|
115
|
+
reducer = UMAP(
|
|
116
116
|
n_components=2,
|
|
117
117
|
n_neighbors=15,
|
|
118
118
|
min_dist=0.1,
|
|
@@ -191,7 +191,7 @@ def name_clusters(
|
|
|
191
191
|
model,
|
|
192
192
|
output_type=ClusterTheme,
|
|
193
193
|
instructions=NAMING_INSTRUCTIONS,
|
|
194
|
-
|
|
194
|
+
retries=3,
|
|
195
195
|
)
|
|
196
196
|
|
|
197
197
|
clusters = data["clusters"]
|
|
@@ -34,6 +34,7 @@ from .config import (
|
|
|
34
34
|
EMBEDDING_MODELS,
|
|
35
35
|
SEARCH_DB_SCHEMA_VERSION,
|
|
36
36
|
)
|
|
37
|
+
from .db import sqlite_ro_uri
|
|
37
38
|
|
|
38
39
|
logger = logging.getLogger(__name__)
|
|
39
40
|
|
|
@@ -359,7 +360,7 @@ def generate_descriptions( # noqa: PLR0913, PLR0915
|
|
|
359
360
|
)
|
|
360
361
|
|
|
361
362
|
# Read version and icon names from the main DB
|
|
362
|
-
main_conn = sqlite3.connect(
|
|
363
|
+
main_conn = sqlite3.connect(sqlite_ro_uri(main_db_path), uri=True)
|
|
363
364
|
try:
|
|
364
365
|
all_names = [
|
|
365
366
|
row[0]
|
|
@@ -404,7 +405,7 @@ def generate_descriptions( # noqa: PLR0913, PLR0915
|
|
|
404
405
|
logger.info("Generating descriptions for %d icons", len(names))
|
|
405
406
|
|
|
406
407
|
# Read SVG content from the main DB
|
|
407
|
-
main_conn = sqlite3.connect(
|
|
408
|
+
main_conn = sqlite3.connect(sqlite_ro_uri(main_db_path), uri=True)
|
|
408
409
|
svgs: dict[str, str] = {}
|
|
409
410
|
try:
|
|
410
411
|
for name in names:
|
|
@@ -663,10 +664,10 @@ def build_search_db(
|
|
|
663
664
|
verbose: Verbose logging.
|
|
664
665
|
"""
|
|
665
666
|
try:
|
|
666
|
-
from
|
|
667
|
+
from candle_embed import TextEmbedding # noqa: PLC0415
|
|
667
668
|
except ImportError:
|
|
668
669
|
raise ImportError(
|
|
669
|
-
"
|
|
670
|
+
"candle-embed is required to build the search database. "
|
|
670
671
|
"Install with: pip install 'python-lucide[search]'"
|
|
671
672
|
) from None
|
|
672
673
|
|
|
@@ -710,7 +711,10 @@ def build_search_db(
|
|
|
710
711
|
embeddings: dict[str, dict[str, object]] = {}
|
|
711
712
|
for model_id, model_cfg in EMBEDDING_MODELS.items():
|
|
712
713
|
texts = [f"{model_cfg.document_prefix}{t}" for t in base_texts]
|
|
713
|
-
embedder = TextEmbedding(
|
|
714
|
+
embedder = TextEmbedding(
|
|
715
|
+
model_name=model_cfg.fastembed_model,
|
|
716
|
+
pooling=model_cfg.pooling,
|
|
717
|
+
)
|
|
714
718
|
vecs = list(embedder.embed(texts))
|
|
715
719
|
embeddings[model_id] = dict(zip(ordered_names, vecs, strict=True))
|
|
716
720
|
logger.info(
|
|
@@ -541,30 +541,19 @@ def _cmd_build_search(args: argparse.Namespace) -> int:
|
|
|
541
541
|
def _first_run_downloads(model: str) -> list[str]:
|
|
542
542
|
"""Human-readable one-time downloads the next search will trigger.
|
|
543
543
|
|
|
544
|
-
Best-effort: peeks at
|
|
544
|
+
Best-effort: peeks at candle-embed's model cache and the search-DB cache;
|
|
545
545
|
any surprise in their layout just means the notice is skipped.
|
|
546
546
|
"""
|
|
547
547
|
from .search import search_available # noqa: PLC0415
|
|
548
548
|
|
|
549
549
|
pending = []
|
|
550
550
|
try:
|
|
551
|
-
from
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
for m in TextEmbedding.list_supported_models()
|
|
558
|
-
if m["model"] == fastembed_name
|
|
559
|
-
)
|
|
560
|
-
hf_repo = (meta.get("sources") or {}).get("hf") or ""
|
|
561
|
-
size_mb = round(meta["size_in_GB"] * 1000)
|
|
562
|
-
model_dir = (
|
|
563
|
-
pathlib.Path(define_cache_dir(None))
|
|
564
|
-
/ f"models--{hf_repo.replace('/', '--')}"
|
|
565
|
-
)
|
|
566
|
-
if hf_repo and not model_dir.exists():
|
|
567
|
-
pending.append(f"embedding model (~{size_mb} MB)")
|
|
551
|
+
from candle_embed import _cache_root, _safe_cache_dir # noqa: PLC0415
|
|
552
|
+
|
|
553
|
+
model_repo = EMBEDDING_MODELS[model].fastembed_model
|
|
554
|
+
model_dir = _safe_cache_dir(_cache_root(), model_repo, "main")
|
|
555
|
+
if not (model_dir / "model.safetensors").exists():
|
|
556
|
+
pending.append("embedding model")
|
|
568
557
|
except Exception:
|
|
569
558
|
pass
|
|
570
559
|
if not search_available():
|
|
@@ -809,8 +798,7 @@ def _cmd_version(_args: argparse.Namespace) -> int:
|
|
|
809
798
|
"""Handle ``lucide version``."""
|
|
810
799
|
from .dev_utils import print_version_status # noqa: PLC0415
|
|
811
800
|
|
|
812
|
-
print_version_status()
|
|
813
|
-
return 0
|
|
801
|
+
return print_version_status()
|
|
814
802
|
|
|
815
803
|
|
|
816
804
|
def _resolve_icons_db(
|
|
@@ -4,9 +4,10 @@ This module contains default configuration values used throughout the package.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
+
from typing import Literal
|
|
7
8
|
|
|
8
9
|
# Default Lucide tag to use when building the icon database
|
|
9
|
-
DEFAULT_LUCIDE_TAG = "1.
|
|
10
|
+
DEFAULT_LUCIDE_TAG = "1.84.0"
|
|
10
11
|
|
|
11
12
|
# Default size for the LRU cache used by lucide_icon function
|
|
12
13
|
DEFAULT_ICON_CACHE_SIZE = 128
|
|
@@ -48,7 +49,7 @@ class EmbeddingModelConfig:
|
|
|
48
49
|
dim: int
|
|
49
50
|
fastembed_model: str = ""
|
|
50
51
|
web_model: str = ""
|
|
51
|
-
pooling:
|
|
52
|
+
pooling: Literal["mean", "cls"] = "mean"
|
|
52
53
|
web_dtype: str = "fp32"
|
|
53
54
|
query_prefix: str = ""
|
|
54
55
|
document_prefix: str = ""
|
|
@@ -10,6 +10,7 @@ import logging
|
|
|
10
10
|
import sqlite3
|
|
11
11
|
import warnings
|
|
12
12
|
import xml.etree.ElementTree as ET
|
|
13
|
+
from xml.sax.saxutils import escape as xml_escape
|
|
13
14
|
|
|
14
15
|
from .config import DEFAULT_ICON_CACHE_SIZE
|
|
15
16
|
from .db import get_db_connection, get_default_db_path
|
|
@@ -258,6 +259,22 @@ def lucide_icon( # noqa: PLR0917 -- public API; positional arguments are suppor
|
|
|
258
259
|
return create_placeholder_svg(icon_name, fallback_text, f"Error: {e}")
|
|
259
260
|
|
|
260
261
|
|
|
262
|
+
def _escape_xml_attr(value: str) -> str:
|
|
263
|
+
"""Escape a string for safe inclusion inside a double-quoted XML attribute."""
|
|
264
|
+
return xml_escape(value, {'"': """, "'": "'"})
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _escape_xml_comment(text: str) -> str:
|
|
268
|
+
"""Sanitize text for safe inclusion inside an XML ``<!-- ... -->`` comment."""
|
|
269
|
+
# XML 1.0 forbids '--' anywhere inside a comment and a trailing '-' before '-->'.
|
|
270
|
+
sanitized = text
|
|
271
|
+
while "--" in sanitized:
|
|
272
|
+
sanitized = sanitized.replace("--", "- -")
|
|
273
|
+
if sanitized.endswith("-"):
|
|
274
|
+
sanitized += " "
|
|
275
|
+
return sanitized
|
|
276
|
+
|
|
277
|
+
|
|
261
278
|
def create_placeholder_svg(
|
|
262
279
|
icon_name: str,
|
|
263
280
|
fallback_text: str | None = None,
|
|
@@ -273,20 +290,20 @@ def create_placeholder_svg(
|
|
|
273
290
|
Returns:
|
|
274
291
|
A string containing an SVG placeholder.
|
|
275
292
|
"""
|
|
276
|
-
display_text = fallback_text if fallback_text is not None else icon_name
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if error_text
|
|
280
|
-
else f"<!-- Icon '{icon_name}' not found -->"
|
|
293
|
+
display_text = xml_escape(fallback_text if fallback_text is not None else icon_name)
|
|
294
|
+
safe_icon_attr = _escape_xml_attr(icon_name)
|
|
295
|
+
comment_body = _escape_xml_comment(
|
|
296
|
+
error_text if error_text else f"Icon '{icon_name}' not found"
|
|
281
297
|
)
|
|
298
|
+
comment = f"<!-- {comment_body} -->"
|
|
282
299
|
|
|
283
300
|
# Using a more robust SVG structure for the placeholder
|
|
284
301
|
# Ensures it's also parsable by ElementTree for consistency in testing if needed
|
|
285
302
|
return f"""{comment}
|
|
286
303
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
|
287
304
|
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
288
|
-
stroke-linejoin="round" class="lucide lucide-{
|
|
289
|
-
data-missing-icon="{
|
|
305
|
+
stroke-linejoin="round" class="lucide lucide-{safe_icon_attr} lucide-placeholder"
|
|
306
|
+
data-missing-icon="{safe_icon_attr}">
|
|
290
307
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
291
308
|
<text x="12" y="14" text-anchor="middle" font-size="8"
|
|
292
309
|
font-family="sans-serif" fill="currentColor">{display_text}</text>
|