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

+6 -17
View File
@@ -15,7 +15,7 @@ from typing import Any
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads, Row
from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, table_word, yearly_amount
from ._shared import add_place, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, place, yearly_amount
log = logging.getLogger(__name__)
@@ -36,13 +36,6 @@ READS = Reads(
_API = "api.ashbyhq.com"
#: `workplaceType` -> `store._remote`'s words. `isRemote` is true for hybrid
#: roles too, so it is only the fallback when the role has no `workplaceType`.
_WORKPLACE = {"remote": "remote", "hybrid": "hybrid", "onsite": "onsite"}
#: `employmentType` -> the app's employment words.
_EMPLOYMENT = {"fulltime": "full_time", "parttime": "part_time", "intern": "internship",
"contract": "contract", "temporary": "temporary"}
def slug_ok(slug: str) -> bool:
@@ -113,12 +106,12 @@ def _salary_text(compensation: dict[str, Any]) -> str:
or compensation.get("scrapeableCompensationSalarySummary") or "")
def _places(j: dict[str, Any], workplace: str | None) -> list[Place]:
def _places(j: dict[str, Any], workplace: str) -> list[Place]:
"""The primary `location`, then each of `secondaryLocations`, in the host's
words. The primary is remote or an office as `workplaceType` says; a
place that names itself remote is remote."""
primary = (j.get("location") or "").strip()
named = [(primary, {"remote": True, "hybrid": False, "onsite": False}.get(workplace or ""))]
named = [(primary, {"remote": True, "hybrid": False, "onsite": False}.get(workplace.lower()))]
named += [(str((s or {}).get("location") or "").strip(), None)
for s in j.get("secondaryLocations") or []]
out: list[Place] = []
@@ -127,10 +120,6 @@ def _places(j: dict[str, Any], workplace: str | None) -> list[Place]:
return out
def _employment(value: Any) -> str | None:
return table_word(_EMPLOYMENT, value, log, "employmentType")
def parse(body: bytes, slug: str) -> list[Row]:
data = json.loads(body)
rows = []
@@ -142,7 +131,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
description = j.get("descriptionHtml") or j.get("descriptionPlain") or ""
compensation = j.get("compensation") or {}
salary_min, salary_max, currency = _salary(compensation.get("summaryComponents") or [])
workplace = _WORKPLACE.get(str(j.get("workplaceType") or "").strip().lower())
workplace = str(j.get("workplaceType") or "").strip()
places = _places(j, workplace)
row: Row = {
"source_id": str(j.get("id") or ""),
@@ -153,13 +142,13 @@ def parse(body: bytes, slug: str) -> list[Row]:
"posted": parse_dt(j.get("publishedAt")),
"department": (j.get("department") or j.get("team") or "").strip(),
"description": strip_html(description),
"remote": workplace or j.get("isRemote"),
"remote": workplace or j.get("isRemote"), # `isRemote` is true for hybrid too
"salary_text": _salary_text(compensation),
"salary_min": salary_min,
"salary_max": salary_max,
"currency": currency,
}
if employment := _employment(j.get("employmentType")):
if employment := str(j.get("employmentType") or "").strip():
row["employment"] = employment
rows.append(row)
return rows