#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 17 18:53:53 2022
@author: alvaro
"""
[docs]
class Importer:
"""Controller class for importing data from an external source to the local Wikibase."""
def __init__(self, dataSource):
"""
Construct.
Args:
entityCreator: object implementing AEntityCreator
dataSource: object implementig ADataSource
"""
self.dataSource = dataSource
[docs]
def import_all(self, pull=True, push=True):
"""
Manages the import process.
"""
self.dataSource.setup()
if pull:
self.dataSource.pull()
if push:
self.dataSource.push()
[docs]
class ADataSource:
"""Abstract base class for reading data from external sources."""
[docs]
def write_data_dump(self):
"""
Write data dump from API.
"""
raise NotImplementedError
[docs]
def process_data(self):
"""
Process data dump.
"""
raise NotImplementedError
[docs]
def pull(self):
"""
Pull data from DataSource
"""
raise NotImplementedError
[docs]
def push(self):
"""
Push data into the MaRDI knowledge graph.
"""
raise NotImplementedError
[docs]
class AConfigParser:
"""Abstract base class for parsing config files"""
[docs]
def parse_config(self):
"""
Parse config file.
Returns:
Dictionary: Dictionary containing config values
"""
[docs]
class ImporterException(Exception):
"""Failed importer operation."""
pass