Compare commits
3 commits
4e5a9e92a7
...
4ba8d29aee
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ba8d29aee | |||
| 7856769cda | |||
| 4b6079d4a3 |
5 changed files with 525 additions and 350 deletions
|
|
@ -1,16 +1,16 @@
|
||||||
steps:
|
steps:
|
||||||
lint_ruff:
|
lint_ruff:
|
||||||
image: python
|
image: ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
||||||
commands:
|
commands:
|
||||||
- pip install ruff
|
- uv tool install ruff
|
||||||
- python --version && poetry --version && ruff --version
|
- python --version && uv --version && ruff --version
|
||||||
- echo "----------------- running ruff lint ------------------"
|
- echo "----------------- running ruff lint ------------------"
|
||||||
- ruff check .
|
- ruff check .
|
||||||
|
|
||||||
lint_black:
|
format_ruff:
|
||||||
image: python
|
image: ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
||||||
commands:
|
commands:
|
||||||
- pip install black
|
- uv tool install ruff
|
||||||
- python --version && poetry --version && black --version
|
- python --version && uv --version && ruff --version
|
||||||
- echo "----------------- running black lint ----------------"
|
- echo "----------------- running ruff format ------------------"
|
||||||
- black --check .
|
- ruff format --check .
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
steps:
|
steps:
|
||||||
pyright:
|
pyright:
|
||||||
image: nikolaik/python-nodejs
|
image: ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
||||||
commands:
|
commands:
|
||||||
- npm install --global pyright
|
- uv tool install pyright
|
||||||
- uv sync
|
- uv sync --locked
|
||||||
- python --version && uv version && pyright --version
|
- python --version && uv --version && pyright --version
|
||||||
- echo "------------- running pyright typecheck -------------"
|
- echo "------------- running pyright typecheck -------------"
|
||||||
- uv run pyright
|
- uv run pyright
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ when:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
pytest:
|
pytest:
|
||||||
image: nikolaik/python-nodejs
|
image: ghcr.io/astral-sh/uv:python3.11-trixie-slim
|
||||||
commands:
|
commands:
|
||||||
- uv sync
|
- uv sync --locked
|
||||||
- python --version && uv version
|
- python --version && uv --version
|
||||||
- echo "------------- running pytest -------------"
|
- echo "------------- running pytest -------------"
|
||||||
- uv run pytest
|
- uv run pytest
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# pyright: strict, reportUnknownMemberType=false
|
# pyright: strict, reportUnknownMemberType=false
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
import papis.logging
|
import papis.logging
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
@ -48,16 +49,14 @@ class PocketBookExtractor:
|
||||||
annotations: list[Annotation] = []
|
annotations: list[Annotation] = []
|
||||||
for bm in html.select("div.bookmark"):
|
for bm in html.select("div.bookmark"):
|
||||||
content = str(
|
content = str(
|
||||||
(bm.select_one("div.bm-text>p") or html.new_string("")).text or "" # pyright: ignore [reportUnknownArgumentType]
|
(bm.select_one("div.bm-text>p") or html.new_string("")).text or ""
|
||||||
)
|
)
|
||||||
note = str(
|
note = str(
|
||||||
(bm.select_one("div.bm-note>p") or html.new_string("")).text or "" # pyright: ignore [reportUnknownArgumentType]
|
(bm.select_one("div.bm-note>p") or html.new_string("")).text or ""
|
||||||
)
|
|
||||||
page = int(
|
|
||||||
(bm.select_one("p.bm-page") or html.new_string("")).text or 0 # pyright: ignore [reportUnknownArgumentType]
|
|
||||||
)
|
)
|
||||||
|
page = int((bm.select_one("p.bm-page") or html.new_string("")).text or 0)
|
||||||
|
|
||||||
el_classes = bm.attrs.get("class", "").split(" ")
|
el_classes = cast("str", bm.attrs.get("class", "")).split(" ")
|
||||||
color = (0, 0, 0)
|
color = (0, 0, 0)
|
||||||
for c in el_classes:
|
for c in el_classes:
|
||||||
if "bm-color-" in c:
|
if "bm-color-" in c:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue