Hosts a to l declare READS: places, teaser, stated seniority and employment
Ashby, BambooHR, Deel, Eightfold, Gem, Greenhouse, HiBob, HR Manager, Jibe, Jobylon and Lever move to feed_url(slug, ask) and page(get, slug, cursor, ask), declare READS with the robots decision, and drop robots_page. Rows carry places (Ashby secondaryLocations, Lever allLocations, Greenhouse offices in place of a Hybrid placeholder), Jobylon keeps its summary as teaser and maps experience and employment, Eightfold reads creationTs as the posting date and Ashby reads workplaceType. Fixtures <name>-places.* and jobylon-teaser.html drive the conformance checks; the eleven names leave UNDECLARED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c0da58da7
commit
f2e652a8da
35 files changed
+1290
-391
No files matched your search
@@ -16,12 +16,32 @@ The field map is ported from `openings.go` in
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._shared import Row, is_web_url, num, only, parse_dt, path_slug_ok, pay_line, yearly_amount
|
||||
from ._contract import Ask, Fields, Place, Reads, Row
|
||||
from ._shared import is_web_url, num, only, parse_dt, path_slug_ok, pay_line, yearly_amount
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
READS = Reads(
|
||||
scope="board", listing="whole", text="listing", complete="whole",
|
||||
places="many",
|
||||
fields=Fields(pay="figures", posted="trusted", remote="stated", country="stated",
|
||||
employment="stated"),
|
||||
robots="api: no robots.txt check needed (public board API), 2026-09-30",
|
||||
)
|
||||
|
||||
#: `categories.commitment` -> the app's employment words. A commitment is free
|
||||
#: text on Lever ("Permanent" is seen too and says nothing about hours).
|
||||
_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "fulltime": "full_time",
|
||||
"part-time": "part_time", "part time": "part_time", "parttime": "part_time",
|
||||
"intern": "intern", "internship": "intern", "contract": "contract",
|
||||
"contractor": "contract", "temporary": "temporary", "freelance": "freelance"}
|
||||
|
||||
NAME = "lever"
|
||||
LABEL = "Lever"
|
||||
@@ -60,7 +80,7 @@ def careers_url(slug: str) -> str:
|
||||
return f"https://jobs.{infix}lever.co/{site}"
|
||||
|
||||
|
||||
def feed_url(slug: str) -> str:
|
||||
def feed_url(slug: str, ask: Ask) -> str:
|
||||
infix, site = _split(slug)
|
||||
return f"https://api.{infix}lever.co/v0/postings/{site}?mode=json"
|
||||
|
||||
@@ -88,6 +108,19 @@ def _salary_text(salary_range: dict[str, Any]) -> str:
|
||||
salary_range.get("currency"), period)
|
||||
|
||||
|
||||
def _places(categories: dict[str, Any]) -> list[Place]:
|
||||
"""`categories.allLocations` (every place of the role, the first being
|
||||
`location`), or `location` alone when the list is missing."""
|
||||
names = [categories.get("location"), *(categories.get("allLocations") or [])]
|
||||
out: list[Place] = []
|
||||
for name in names:
|
||||
text = str(name or "").strip()
|
||||
if text and text not in (p["text"] for p in out):
|
||||
out.append({"text": text, "remote": True if re.search(r"\bremote\b", text, re.I)
|
||||
else None})
|
||||
return out
|
||||
|
||||
|
||||
def parse(body: bytes, slug: str) -> list[Row]:
|
||||
data = json.loads(body)
|
||||
if not isinstance(data, list):
|
||||
@@ -104,10 +137,12 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
salary_min, salary_max, currency = yearly_amount(
|
||||
salary_range.get("min"), salary_range.get("max"), salary_range.get("currency"),
|
||||
salary_range.get("interval"), {"per-year-salary": 1, "per-month-salary": 12})
|
||||
rows.append({
|
||||
places = _places(categories)
|
||||
row: Row = {
|
||||
"source_id": str(j.get("id") or ""),
|
||||
"title": title,
|
||||
"location": (categories.get("location") or "").strip(),
|
||||
"places": places,
|
||||
"location": "; ".join(p["text"] for p in places),
|
||||
"url": url,
|
||||
"posted": parse_dt(j.get("createdAt")),
|
||||
"department": (categories.get("department") or categories.get("team") or "").strip(),
|
||||
@@ -117,5 +152,17 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
"salary_min": salary_min,
|
||||
"salary_max": salary_max,
|
||||
"currency": currency,
|
||||
})
|
||||
}
|
||||
# `country` is one code, for a role at one place; over several it would
|
||||
# gate the others by the first's country.
|
||||
country = str(j.get("country") or "").strip().upper()
|
||||
if len(places) == 1 and re.fullmatch(r"[A-Z]{2}", country):
|
||||
row["country"] = country
|
||||
commitment = str(categories.get("commitment") or "").strip()
|
||||
if commitment:
|
||||
if employment := _EMPLOYMENT.get(commitment.lower()):
|
||||
row["employment"] = employment
|
||||
else:
|
||||
log.debug("lever: unknown commitment %r", commitment)
|
||||
rows.append(row)
|
||||
return rows
|
||||
Reference in new issue
Block a user