Coverage for ramose / _constants.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-07-01 13:49 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-07-01 13:49 +0000
1# SPDX-FileCopyrightText: 2018-2021 Silvio Peroni <silvio.peroni@unibo.it>
2# SPDX-FileCopyrightText: 2020-2021 Marilena Daquino <marilena.daquino2@unibo.it>
3# SPDX-FileCopyrightText: 2022 Davide Brembilla
4# SPDX-FileCopyrightText: 2024 Ivan Heibi <ivan.heibi2@unibo.it>
5# SPDX-FileCopyrightText: 2025 Sergei Slinkin
6# SPDX-FileCopyrightText: 2026 Arcangelo Massari <arcangelo.massari@unibo.it>
7#
8# SPDX-License-Identifier: ISC
10from requests import Session as _RequestsSession
12FIELD_TYPE_RE = r"([^\(\s]+)\(([^\)]+)\)"
13PARAM_NAME = r"{([^{}\(\)]+)}"
14DEFAULT_HTTP_TIMEOUT = 60
15FORMAT_PARTS_WITH_MEDIA_TYPE = 3
17FORMAT_MEDIA_TYPES = {
18 "json": "application/json",
19 "csv": "text/csv",
20}
23def media_type_for_format(fmt: str) -> str | None:
24 return FORMAT_MEDIA_TYPES.get((fmt or "").strip().lower())
27_http_session = _RequestsSession()
29_backend_auth: dict[str, str] = {}
32def backend_auth_header(endpoint_url: str) -> dict[str, str]:
33 """Return the Authorization header configured for a specific SPARQL endpoint, or an empty dict."""
34 value = _backend_auth.get(endpoint_url)
35 return {"Authorization": value} if value else {}