Readers ashby to lever hand on the host's words; their word tables move to app/prep/hosts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 10:54:19 +02:00
1 parent a66aac95cf
commit 6c7ce1090d
37 files changed
+504 -171

No files matched your search

+7 -20
View File
@@ -23,7 +23,7 @@ from typing import Any
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads, Row
from ._shared import Get, label_slug_ok, only, parse_dt, place, table_word
from ._shared import Get, label_slug_ok, only, parse_dt, place
log = logging.getLogger(__name__)
@@ -34,13 +34,6 @@ READS = Reads(
robots="read: robots.txt allows /careers (checked 2026-09-29)",
)
#: `employmentStatusLabel` -> the app's employment words. BambooHR's labels are
#: the company's own ("Full-Time", "Part-Time", "Contract", "Intern").
_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time",
"part time": "part_time", "contract": "contract", "contractor": "contract",
"temporary": "temporary", "intern": "internship", "internship": "internship",
"freelance": "freelance"}
NAME = "bamboohr"
LABEL = "BambooHR"
PATTERNS = (
@@ -49,9 +42,6 @@ PATTERNS = (
r"https?://(?!(?:app|resources|documentation|help)\.)([a-z0-9-]+)\.bamboohr\.com",
)
#: `locationType` -> `store._remote`'s words. Anything else says nothing.
_REMOTE = {"0": "onsite", "1": "remote", "2": "hybrid"}
#: Sent on the detail read: without it the same URL answers the page's HTML.
_JSON = {"Accept": "application/json"}
@@ -76,10 +66,11 @@ def feed_url(slug: str, ask: Ask) -> str:
return f"https://{host(slug)}/careers/list"
def _remote(j: dict[str, Any]) -> str | None:
def _remote(j: dict[str, Any]) -> bool | str | None:
"""`isRemote` when true, else `locationType` as the host writes it ("0", "1", "2")."""
if j.get("isRemote") is True:
return "remote"
return _REMOTE.get(str(j.get("locationType") if j.get("locationType") is not None else ""))
return True
return None if j.get("locationType") is None else str(j["locationType"]).strip() or None
def _place(j: dict[str, Any]) -> str:
@@ -99,10 +90,6 @@ def _places(j: dict[str, Any]) -> list[Place]:
return [place(text)] if text else []
def _employment(j: dict[str, Any]) -> str | None:
return table_word(_EMPLOYMENT, j.get("employmentStatusLabel"), log, "employmentStatusLabel")
def parse(body: bytes, slug: str) -> list[Row]:
"""`/careers/list` -> `{"meta": {"totalCount": n}, "result": [...]}`. A
role has `id`, `jobOpeningName`, `departmentLabel`, `location` (`city`,
@@ -136,7 +123,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
"remote": _remote(j),
"salary_text": "", # the list states no pay; the detail's `compensation` was null
}
if employment := _employment(j):
if employment := str(j.get("employmentStatusLabel") or "").strip():
row["employment"] = employment
out.append(row)
return out
@@ -160,6 +147,6 @@ def detail(get: Get, slug: str, row: Row) -> dict[str, Any]:
if place := _place(opening):
out["location"] = place
out["places"] = _places(opening)
if remote := _remote(opening):
if (remote := _remote(opening)) is not None:
out["remote"] = remote
return out