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 -8
View File
@@ -13,7 +13,7 @@ from collections.abc import Callable
from typing import Any
from ._contract import Ask, Fields, Place, Reads
from ._shared import Get, Page, Row, only, parse_dt, path_slug_ok
from ._shared import Get, Page, Row, add_place, country_if_single, only, parse_dt, path_slug_ok, table_word
log = logging.getLogger(__name__)
@@ -82,8 +82,7 @@ def _places(job: dict[str, Any], remote: bool) -> tuple[list[Place], set[str]]:
if part and part not in parts:
parts.append(part)
text = ", ".join(parts)
if text and text not in (p["text"] for p in found):
found.append({"text": text, "remote": remote})
add_place(found, {"text": text, "remote": remote})
if code := str(loc.get("countryCode") or "").strip().upper():
codes.add(code)
return found, codes
@@ -107,9 +106,6 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
continue
remote = bool(j.get("remote")) or j.get("workplace") == "remote"
places, codes = _places(j, remote)
kind = str(j.get("type") or "").strip().lower()
if kind and kind not in _EMPLOYMENT:
log.debug("workable: unknown type %r", kind)
dept = j.get("department") or ""
if isinstance(dept, list):
dept = ", ".join(d for d in dept if d)
@@ -124,7 +120,7 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
"description": "",
"remote": remote,
"salary_text": "", # Workable's list endpoint states no pay at all
"country": next(iter(codes)) if len(codes) == 1 else None,
"employment": _EMPLOYMENT.get(kind),
"country": country_if_single(codes),
"employment": table_word(_EMPLOYMENT, j.get("type"), log, "type"),
})
return out