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 -10
View File
@@ -15,7 +15,7 @@ from typing import Any
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads
from ._shared import Row, is_web_url, label_slug_ok, num, only, parse_dt, pay_line, yearly_amount
from ._shared import Row, add_place, country_if_single, is_web_url, label_slug_ok, num, only, parse_dt, pay_line, table_word, yearly_amount
log = logging.getLogger(__name__)
@@ -83,12 +83,7 @@ def _salary_text(salary: dict[str, Any]) -> str:
def _seniority(code: str) -> str | None:
key = code.strip().lower()
if key not in _SENIORITY:
if key:
log.debug("recruitee: unknown experience_code %r", code)
return None
return _SENIORITY[key] or None
return table_word(_SENIORITY, code, log, "experience_code")
def _employment(code: str) -> str | None:
@@ -112,8 +107,8 @@ def _places(offer: dict[str, Any]) -> tuple[list[Place], set[str]]:
def add(text: str) -> None:
text = text.strip()
if text and text.lower() not in _NO_PLACE and text not in (p["text"] for p in found):
found.append({"text": text, "remote": None})
if text.lower() not in _NO_PLACE:
add_place(found, {"text": text, "remote": None})
for loc in offer.get("locations") or []:
if not isinstance(loc, dict):
@@ -165,7 +160,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
"salary_min": salary_min,
"salary_max": salary_max,
"currency": currency,
"country": next(iter(codes)) if len(codes) == 1 else None,
"country": country_if_single(codes),
"seniority": _seniority(str(j.get("experience_code") or "")),
"employment": _employment(str(j.get("employment_type_code") or "")),
})