Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/config.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import os | import os | ||||
from typing import Any, Dict | from typing import Any, Dict | ||||
from swh.core import config | from swh.core import config | ||||
from swh.deposit import __version__ | from swh.deposit import __version__ | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
from swh.scheduler.interface import SchedulerInterface | from swh.scheduler.interface import SchedulerInterface | ||||
from swh.storage import get_storage | |||||
from swh.storage.interface import StorageInterface | |||||
# IRIs (Internationalized Resource identifier) sword 2.0 specified | # IRIs (Internationalized Resource identifier) sword 2.0 specified | ||||
EDIT_SE_IRI = "edit_se_iri" | EDIT_SE_IRI = "edit_se_iri" | ||||
EM_IRI = "em_iri" | EM_IRI = "em_iri" | ||||
CONT_FILE_IRI = "cont_file_iri" | CONT_FILE_IRI = "cont_file_iri" | ||||
SD_IRI = "servicedocument" | SD_IRI = "servicedocument" | ||||
COL_IRI = "upload" | COL_IRI = "upload" | ||||
STATE_IRI = "state_iri" | STATE_IRI = "state_iri" | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | class APIConfig: | ||||
def __init__(self): | def __init__(self): | ||||
self.config: Dict[str, Any] = config.load_from_envvar(DEFAULT_CONFIG) | self.config: Dict[str, Any] = config.load_from_envvar(DEFAULT_CONFIG) | ||||
self.scheduler: SchedulerInterface = get_scheduler(**self.config["scheduler"]) | self.scheduler: SchedulerInterface = get_scheduler(**self.config["scheduler"]) | ||||
self.tool = { | self.tool = { | ||||
"name": "swh-deposit", | "name": "swh-deposit", | ||||
"version": __version__, | "version": __version__, | ||||
"configuration": {"sword_version": "2"}, | "configuration": {"sword_version": "2"}, | ||||
} | } | ||||
self.storage_metadata: StorageInterface = get_storage( | |||||
**self.config["storage_metadata"] | |||||
) |