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:
1 parent
a66aac95cf
commit
6c7ce1090d
37 files changed
+504
-171
No files matched your search
+5
-14
@@ -24,7 +24,7 @@ from typing import Any
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._contract import Ask, Fields, Reads, Row
|
||||
from ._shared import num, only, parse_dt, pay_line, table_word
|
||||
from ._shared import num, only, parse_dt, pay_line
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -59,15 +59,6 @@ _PUSH = re.compile(r'self\.__next_f\.push\(\[1,("(?:[^"\\]|\\.)*")\]\)')
|
||||
_ROW = re.compile(rb"([0-9a-f]*):")
|
||||
_TEXT = re.compile(rb"T([0-9a-f]+),")
|
||||
|
||||
#: Deel's `workArrangementEnum` -> `store._remote`'s words.
|
||||
_REMOTE = {"ON_SITE": "onsite", "HYBRID": "hybrid", "REMOTE": "remote"}
|
||||
|
||||
#: The name of a `jobEmploymentTypes` entry -> the app's employment words.
|
||||
_EMPLOYMENT = {"full-time": "full_time", "full time": "full_time", "part-time": "part_time",
|
||||
"part time": "part_time", "contract": "contract", "contractor": "contract",
|
||||
"consultant": "contract", "temporary": "temporary", "intern": "internship",
|
||||
"internship": "internship", "freelance": "freelance"}
|
||||
|
||||
|
||||
def slug_ok(slug: str) -> bool:
|
||||
return bool(_SLUG.fullmatch(slug))
|
||||
@@ -121,10 +112,10 @@ def _postings(body: bytes) -> tuple[list[dict[str, Any]], dict[str, str]]:
|
||||
|
||||
|
||||
def _employment(job: dict[str, Any]) -> str | None:
|
||||
"""The first `jobEmploymentTypes` entry that names a known type."""
|
||||
"""The name of the first `jobEmploymentTypes` entry that has one."""
|
||||
for entry in job.get("jobEmploymentTypes") or []:
|
||||
name = ((entry or {}).get("employmentType") or {}).get("name")
|
||||
if found := table_word(_EMPLOYMENT, name, log, "employment type"):
|
||||
if found := str(name or "").strip():
|
||||
return found
|
||||
return None
|
||||
|
||||
@@ -155,7 +146,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
description = p.get("richtextDescription") or ""
|
||||
if description.startswith("$"):
|
||||
description = stream.get(description[1:], "")
|
||||
arrangement = str(job.get("workArrangementEnum") or "")
|
||||
arrangement = str(job.get("workArrangementEnum") or "").strip()
|
||||
remote = {"REMOTE": True, "HYBRID": False, "ON_SITE": False}.get(arrangement)
|
||||
row: Row = {
|
||||
"source_id": post_id,
|
||||
@@ -166,7 +157,7 @@ def parse(body: bytes, slug: str) -> list[Row]:
|
||||
"posted": parse_dt(published.get("createdAt") or p.get("createdAt")),
|
||||
"department": ", ".join(dict.fromkeys(departments)),
|
||||
"description": html.unescape(strip_html(description)),
|
||||
"remote": _REMOTE.get(str(job.get("workArrangementEnum") or "")),
|
||||
"remote": arrangement or None,
|
||||
"salary_text": (pay_line(num(pay.get("minAmount")), num(pay.get("maxAmount")),
|
||||
pay.get("currencyIsoCode"), "")
|
||||
if p.get("isCompensationVisible") else ""),
|
||||
|
||||
Reference in new issue
Block a user