Page MenuHomec4science

repo_importer.py
No OneTemporary

File Metadata

Created
Mon, Nov 4, 11:43

repo_importer.py

# -*- coding: utf-8 -*-
import logging
import copy
from .. import export
from .. import colored
from .. import Repo
from . import Importer
__author__ = "Nicolas Richart"
__copyright__ = "Copyright (C) 2016, EPFL (Ecole Polytechnique Fédérale " \
"de Lausanne) - SCITAS (Scientific IT and Application " \
"Support)"
__credits__ = ["Nicolas Richart"]
__license__ = "BSD"
__version__ = "0.1"
__maintainer__ = "Nicolas Richart"
__email__ = "nicolas.richart@epfl.ch"
_logger = logging.getLogger(__name__)
@export
class RepoImporter(Importer):
__default_import_scheme = {'type': 'git'}
def __init__(self, name, config, user_db, **kwargs):
super().__init__(name, config,
self.__default_import_scheme, **kwargs)
self._db = user_db
_logger.info(
'Initializing importer for Repo {0}'
' with configuration: {1}'.format(self._colored_name,
self._config))
self._in_repo = Repo(name=name, keyring=self._keyring, **config,
dry_run=self._dry_run)
def transfer(self):
_logger.info('Locking for repo: {0}'.format(self._colored_name))
import_scheme = copy.copy(self._config['import-scheme'])
if import_scheme['type'] == 'same':
import_scheme['type'] = self._in_repo.repo_type
_logger.debug(' --> repo info {0}'.format(colored(self._config,
attrs=['bold'])))
_name = import_scheme.pop('name', self._name).format(
original_name=self._name)
self._out_repo = Repo(name=_name,
keyring=self._keyring,
**import_scheme,
dry_run=self._dry_run)
self._out_repo.create()

Event Timeline