Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/config.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2018 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 | ||||
import logging | import logging | ||||
from typing import Any, Dict, Tuple | |||||
from swh.core.config import SWHConfig | from swh.core.config import SWHConfig | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
# 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' | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | DEFAULT_CONFIG = { | ||||
'scheduler': ('dict', { | 'scheduler': ('dict', { | ||||
'cls': 'remote', | 'cls': 'remote', | ||||
'args': { | 'args': { | ||||
'url': 'http://localhost:5008/' | 'url': 'http://localhost:5008/' | ||||
} | } | ||||
}) | }) | ||||
} | } | ||||
ADDITIONAL_CONFIG = {} | ADDITIONAL_CONFIG = {} # type: Dict[str, Tuple[str, Any]] | ||||
def __init__(self, **config): | def __init__(self, **config): | ||||
super().__init__() | super().__init__() | ||||
self.config = self.parse_config_file( | self.config = self.parse_config_file( | ||||
additional_configs=[self.ADDITIONAL_CONFIG]) | additional_configs=[self.ADDITIONAL_CONFIG]) | ||||
self.config.update(config) | self.config.update(config) | ||||
self.log = logging.getLogger('swh.deposit') | self.log = logging.getLogger('swh.deposit') | ||||
if self.config['checks']: | if self.config['checks']: | ||||
self.scheduler = get_scheduler(**self.config['scheduler']) | self.scheduler = get_scheduler(**self.config['scheduler']) |