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

+4 -5
View File
@@ -39,7 +39,7 @@ from desk.sources import strip_html
from ._contract import Ask, Fields, Filters, Place, Reads
from ._countries import code_of
from ._shared import Get, Page, Row, only, parse_dt
from ._shared import Get, Page, Row, add_place, only, parse_dt, table_word
log = logging.getLogger(__name__)
@@ -320,7 +320,7 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
out["location"] = "; ".join(p["text"] for p in places)
if len(places) == 1 and (code := _country_code(posting)):
out["country"] = code
if employment := _EMPLOYMENT.get(str(posting.get("timeType") or "").strip().lower()):
if employment := table_word(_EMPLOYMENT, posting.get("timeType"), log, "timeType"):
out["employment"] = employment
if posted := parse_dt(posting.get("startDate")):
out["posted"] = posted
@@ -344,9 +344,8 @@ def _places(posting: dict[str, Any], remote: str | None) -> list[Place]:
(LEGO's "Billund") gets it from the role's `country`."""
found: list[Place] = []
for name in [posting.get("location"), *(posting.get("additionalLocations") or [])]:
place = _place(name, remote)
if place and place["text"] not in (p["text"] for p in found):
found.append(place)
if place := _place(name, remote):
add_place(found, place)
country = str((posting.get("country") or {}).get("descriptor") or "").strip()
if len(found) == 1 and country and country.lower() not in found[0]["text"].lower():
found[0]["text"] += f", {country}"