Share the readers' place, table-lookup and country helpers, unify the employment vocabulary, and list the enrich switch with the stages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 10:13:24 +02:00
1 parent ca80219bbb
commit 903b69b6d3
34 files changed
+290 -207

No files matched your search

+5 -11
View File
@@ -24,7 +24,7 @@ from typing import Any
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads, Row
from ._shared import is_web_url, num, only, parse_dt, path_slug_ok, pay_line, yearly_amount
from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, table_word, yearly_amount
log = logging.getLogger(__name__)
@@ -40,7 +40,7 @@ READS = Reads(
#: text on Lever ("Permanent" is seen too and says nothing about hours).
_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "fulltime": "full_time",
"part-time": "part_time", "part time": "part_time", "parttime": "part_time",
"intern": "intern", "internship": "intern", "contract": "contract",
"intern": "internship", "internship": "internship", "contract": "contract",
"contractor": "contract", "temporary": "temporary", "freelance": "freelance"}
NAME = "lever"
@@ -115,9 +115,7 @@ def _places(categories: dict[str, Any]) -> list[Place]:
out: list[Place] = []
for name in names:
text = str(name or "").strip()
if text and text not in (p["text"] for p in out):
out.append({"text": text, "remote": True if re.search(r"\bremote\b", text, re.I)
else None})
add_place(out, place(text))
return out
@@ -158,11 +156,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
country = str(j.get("country") or "").strip().upper()
if len(places) == 1 and re.fullmatch(r"[A-Z]{2}", country):
row["country"] = country
commitment = str(categories.get("commitment") or "").strip()
if commitment:
if employment := _EMPLOYMENT.get(commitment.lower()):
row["employment"] = employment
else:
log.debug("lever: unknown commitment %r", commitment)
if employment := table_word(_EMPLOYMENT, categories.get("commitment"), log, "commitment"):
row["employment"] = employment
rows.append(row)
return rows