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:
1 parent
ca80219bbb
commit
903b69b6d3
34 files changed
+290
-207
No files matched your search
+7
-13
@@ -38,7 +38,7 @@ from typing import Any
|
||||
from desk.sources import strip_html
|
||||
|
||||
from ._contract import Ask, Fields, Place, Reads, Row
|
||||
from ._shared import Get, Page, only, parse_dt
|
||||
from ._shared import Get, Page, add_place, only, parse_dt, place, table_word
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -50,9 +50,9 @@ READS = Reads(
|
||||
)
|
||||
|
||||
#: `employment_type` -> the app's employment words.
|
||||
_EMPLOYMENT = {"FULL_TIME": "full_time", "PART_TIME": "part_time", "CONTRACTOR": "contract",
|
||||
"CONTRACT": "contract", "TEMPORARY": "temporary", "INTERN": "intern",
|
||||
"INTERNSHIP": "intern", "FREELANCE": "freelance"}
|
||||
_EMPLOYMENT = {"full_time": "full_time", "part_time": "part_time", "contractor": "contract",
|
||||
"contract": "contract", "temporary": "temporary", "intern": "internship",
|
||||
"internship": "internship", "freelance": "freelance"}
|
||||
|
||||
NAME = "jibe"
|
||||
LABEL = "Jibe"
|
||||
@@ -120,9 +120,7 @@ def _places(j: dict[str, Any]) -> list[Place]:
|
||||
out: list[Place] = []
|
||||
for part in line.split(";"):
|
||||
text = part.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})
|
||||
add_place(out, place(text))
|
||||
return out
|
||||
|
||||
|
||||
@@ -162,11 +160,7 @@ def rows(data: dict[str, Any], slug: str) -> list[Row]:
|
||||
code = str(j.get("country_code") or "").strip().upper()
|
||||
if len(places) == 1 and re.fullmatch(r"[A-Z]{2}", code):
|
||||
row["country"] = code
|
||||
kind = str(j.get("employment_type") or "").strip()
|
||||
if kind:
|
||||
if employment := _EMPLOYMENT.get(kind.upper()):
|
||||
row["employment"] = employment
|
||||
else:
|
||||
log.debug("jibe: unknown employment_type %r", kind)
|
||||
if employment := table_word(_EMPLOYMENT, j.get("employment_type"), log, "employment_type"):
|
||||
row["employment"] = employment
|
||||
out.append(row)
|
||||
return out
|
||||
Reference in new issue
Block a user