Files
jobboard/plugins/readers/personio.py
T
WolfandClaude Fable 5.1 2349fc424b Require READS, search params and a dated robots record; record robots.txt per requested path
Every reader declares, so undeclared(), the scope() fallback, robots_page and
ROBOTS_ANY_CASE go. A search provider needs PARAMS and clean_params, a row may
carry company, places gains none. Each robots record names the paths the
reader requests, from robots.txt read again on 2026-09-30. Platsbanken states
remote, HR Manager states no place.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-30 15:51:13 +02:00

140 lines
5.3 KiB
Python

"""Personio: `personio:<subdomain>`, the whole board in one XML answer from
the company's own subdomain of jobs.personio.de.
Written from one real board on 2026-09-23; jobhunt-hq did not read
Personio.
"""
from __future__ import annotations
import xml.etree.ElementTree as ET
from collections.abc import Callable
from desk.sources import strip_html
from ._contract import Ask, Fields, Place, Reads
from ._shared import Row, add_place, label_slug_ok, num, only, parse_dt, pay_line, place, yearly_amount
NAME = "personio"
LABEL = "Personio"
RANK = 70
PATTERNS = (r"https?://([a-z0-9-]+)\.jobs\.personio\.(?:de|com)",)
READS = Reads(
scope="board", listing="whole", text="listing", complete="whole",
places="many",
fields=Fields(pay="figures", posted="trusted", seniority="stated", employment="stated"),
robots=("read: /xml on <slug>.jobs.personio.de, whose /robots.txt answers 404, so "
"nothing is disallowed (penneo, checked 2026-09-30)"),
)
#: Personio's `salaryInformation/type` spellings, to the plain period word
#: `pay_line` wants ("yearly" -> "year"). Anything else is passed through.
_PERIODS = {"yearly": "year", "monthly": "month", "hourly": "hour",
"daily": "day", "weekly": "week"}
def slug_ok(slug: str) -> bool:
return label_slug_ok(slug)
def allowed(slug: str) -> Callable[[str], bool]:
"""The company's own subdomain, so one company's slug cannot pass for
another's."""
return only(f"{slug}.jobs.personio.de")
def careers_url(slug: str) -> str:
return f"https://{slug}.jobs.personio.de"
def feed_url(slug: str, ask: Ask = Ask()) -> str:
return f"https://{slug}.jobs.personio.de/xml"
def probe_url(slug: str) -> str:
return feed_url(slug)
def probe_ok(body: bytes) -> bool:
return b"<position>" in body
def _salary_text(salary_info: ET.Element) -> str:
"""One line from a `<salaryInformation>` element, whatever its `type`,
including an hourly or daily one that `yearly_amount` drops from the
columns."""
period_raw = (salary_info.findtext("type") or "").strip().lower()
period = _PERIODS.get(period_raw, period_raw)
return pay_line(num(salary_info.findtext("min")), num(salary_info.findtext("max")),
salary_info.findtext("currencyCode"), period)
def _employment(position: ET.Element) -> str | None:
"""The host's word for the contract, or, for a `permanent` one (which says
nothing about the hours), the `schedule`."""
contract = (position.findtext("employmentType") or "").strip()
schedule = (position.findtext("schedule") or "").strip()
if contract.lower() in ("", "permanent") and schedule:
return schedule
return contract or None
def _places(position: ET.Element) -> list[Place]:
"""The `office` and every `additionalOffices/office`, each once. The feed
has no remote flag; an office named "Remote" or "Berlin (Remote)" is
remote, any other says nothing."""
found: list[Place] = []
names = [position.findtext("office"),
*(o.text for o in position.findall("additionalOffices/office"))]
for name in names:
text = (name or "").strip()
add_place(found, place(text))
return found
def parse(body: bytes, slug: str) -> list[Row]:
"""`{slug}.jobs.personio.de/xml` -> `<workzag-jobs><position>...`. No job
URL in the feed itself; Personio's own page is `/job/{id}`, confirmed
live against a real posting (2026-09-23). `additionalOffices` lists the
other places of a role (116 of 320 at the three boards read); `seniority`
is one of entry-level, experienced, executive, student, and `schedule` and
`employmentType` state the hours and the contract."""
root = ET.fromstring(body)
rows = []
for position in root.findall("position"):
job_id = (position.findtext("id") or "").strip()
title = (position.findtext("name") or "").strip()
if not job_id or not title:
continue
description = " ".join(
(value.text or "") for value in position.findall("jobDescriptions/jobDescription/value"))
salary_info = position.find("salaryInformation")
salary_min = salary_max = None
currency = ""
salary_text = ""
if salary_info is not None:
salary_min, salary_max, currency = yearly_amount(
salary_info.findtext("min"), salary_info.findtext("max"),
salary_info.findtext("currencyCode"), salary_info.findtext("type"),
{"yearly": 1, "monthly": 12})
salary_text = _salary_text(salary_info)
places = _places(position)
rows.append({
"source_id": job_id,
"title": title,
"places": places,
"location": "; ".join(p["text"] for p in places),
"url": f"https://{slug}.jobs.personio.de/job/{job_id}",
"posted": parse_dt(position.findtext("createdAt")),
"department": (position.findtext("department") or "").strip(),
"description": strip_html(description),
"seniority": (position.findtext("seniority") or "").strip() or None,
"employment": _employment(position),
"salary_text": salary_text,
"salary_min": salary_min,
"salary_max": salary_max,
"currency": currency,
})
return rows