This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from __future__ import annotations
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from abc import ABC, abstractmethod
|
||||
@@ -8,7 +8,6 @@ from bs4 import BeautifulSoup
|
||||
|
||||
from .base import ExtractedJob, ExtractionResult, FieldEvidence
|
||||
|
||||
|
||||
CLOSED_STATUSES = {
|
||||
"closed",
|
||||
"inactive",
|
||||
@@ -51,7 +50,7 @@ def _first_text(data, *candidates):
|
||||
value = data.get(candidate) if isinstance(data, dict) else None
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(value, (list, tuple)):
|
||||
if isinstance(value, list | tuple):
|
||||
for item in value:
|
||||
text = _to_text(item)
|
||||
if text:
|
||||
@@ -114,7 +113,7 @@ def _as_text(value) -> str:
|
||||
|
||||
def _extract_payload(content: str):
|
||||
try:
|
||||
return json.loads(content)
|
||||
return json.loads(content.lstrip("\ufeff"))
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
soup = BeautifulSoup(content, "lxml")
|
||||
@@ -123,7 +122,7 @@ def _extract_payload(content: str):
|
||||
if not script_text:
|
||||
continue
|
||||
try:
|
||||
return json.loads(script_text)
|
||||
return json.loads(script_text.lstrip("\ufeff"))
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
return None
|
||||
@@ -139,8 +138,7 @@ class _AtsAdapter(ABC):
|
||||
closed_statuses = CLOSED_STATUSES
|
||||
|
||||
@abstractmethod
|
||||
def _extract_records(self, payload) -> list[dict[str, object]]:
|
||||
...
|
||||
def _extract_records(self, payload) -> list[dict[str, object]]: ...
|
||||
|
||||
def _supports_url(self, url: str) -> bool:
|
||||
host = (urlsplit(url).hostname or "").lower()
|
||||
@@ -191,7 +189,7 @@ class _AtsAdapter(ABC):
|
||||
location_raw = ", ".join(location_values)
|
||||
|
||||
location = location_raw
|
||||
location_parts = [part.strip() for part in _to_text(location).split(",") if part.strip()]
|
||||
[part.strip() for part in _to_text(location).split(",") if part.strip()]
|
||||
region = _first_text(
|
||||
record,
|
||||
"region",
|
||||
@@ -343,7 +341,7 @@ class _AtsAdapter(ABC):
|
||||
valid_through=valid_through,
|
||||
employment_types=employment_types,
|
||||
workplace_type=workplace_type,
|
||||
raw=record,
|
||||
raw=record.get("__raw__", record),
|
||||
evidence=evidence,
|
||||
)
|
||||
|
||||
@@ -389,7 +387,9 @@ class _AtsAdapter(ABC):
|
||||
warnings: list[str] = []
|
||||
if not jobs:
|
||||
warnings.append("Geen actieve ATS-vacatures gevonden")
|
||||
return ExtractionResult(jobs, self.parser_key, self.parser_version, 0.9 if jobs else 0.0, warnings)
|
||||
return ExtractionResult(
|
||||
jobs, self.parser_key, self.parser_version, 0.9 if jobs else 0.0, warnings
|
||||
)
|
||||
|
||||
|
||||
class GreenhouseAdapter(_AtsAdapter):
|
||||
@@ -452,6 +452,12 @@ class LeverAdapter(_AtsAdapter):
|
||||
break
|
||||
value = value[key]
|
||||
if isinstance(value, dict):
|
||||
if path == ("position",):
|
||||
raw_payload = {
|
||||
"position": value,
|
||||
"work_type": _to_text(value.get("workplaceType")),
|
||||
}
|
||||
return [{**value, "__raw__": raw_payload}]
|
||||
return [value]
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user