Compare commits

..

3 commits

Author SHA1 Message Date
682b7577de
chore: Remove redundant cast
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/static_analysis Pipeline failed
ci/woodpecker/push/test Pipeline failed
2024-11-30 21:47:38 +01:00
ddaa75f44b
chore: Change woodpecker ci to use uv 2024-11-30 21:45:59 +01:00
9c80281220
fix: Respect minimum color similarity option
Previously we would always assign a minimum color similarity of 1.0,
regardless of the option set. Now we set a minimum similarity according
to the option set in the configuration, otherwise the default set for
that option and fall back to a simple default value declared at the top
of the file.
2024-11-30 21:45:29 +01:00
4 changed files with 13 additions and 12 deletions

View file

@ -3,7 +3,7 @@ steps:
image: nikolaik/python-nodejs
commands:
- npm install --global pyright
- poetry install
- python --version && poetry --version && pyright --version
- uv sync
- python --version && uv version && pyright --version
- echo "------------- running pyright typecheck -------------"
- poetry run pyright
- uv run pyright

View file

@ -3,9 +3,9 @@ when:
steps:
pytest:
image: ghcr.io/withlogicco/poetry:1.5.1
image: nikolaik/python-nodejs
commands:
- poetry install
- python --version && poetry --version
- uv sync
- python --version && uv version
- echo "------------- running pytest -------------"
- poetry run pytest
- uv run pytest

View file

@ -37,12 +37,17 @@ class Annotation:
page: int = 0,
tag: str = "",
type: str = "Highlight",
minimum_similarity_color: float | None = None,
) -> None:
self.file = file
self._color = color
self.content = content
self.note = note
self.page = page
self.minimum_similarity_color = minimum_similarity_color or (
papis.config.getfloat("minimum_similarity_color", "plugins.extract")
or COLOR_SIMILARITY_MINIMUM_FALLBACK
)
self.tag = tag or self._tag_from_colorname(self.colorname or "")
self.type = type
@ -82,10 +87,7 @@ class Annotation:
"""
annot_colors = self.color or (0.0, 0.0, 0.0)
nearest = None
minimum_similarity = (
papis.config.getfloat("minimum_similarity_color", "plugins.extract")
or COLOR_SIMILARITY_MINIMUM_FALLBACK
)
minimum_similarity = self.minimum_similarity_color
for name, values in COLORS.items():
similarity_ratio = self._color_similarity_ratio(values, annot_colors)
if similarity_ratio >= minimum_similarity:

View file

@ -35,7 +35,6 @@ class PdfExtractor:
for (
page
) in doc: # pyright: ignore [reportUnknownVariableType] - missing stub
page = cast(mu.Page, page)
annot: mu.Annot
for annot in page.annots():
quote, note = self._retrieve_annotation_content(page, annot)