From fd36183afbc4c395357f02c01b1ba87a23f328e0 Mon Sep 17 00:00:00 2001
From: Maximilian Schulz <maximilian.schulz@hs-hannover.de>
Date: Mon, 31 Mar 2014 11:37:27 +0200
Subject: [PATCH] [TASK] Adds can_execute methods for loaders
Before this commit every loader just used the
can_execute of the AbstractLoader.
---
hshetl/loaders.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hshetl/loaders.py b/hshetl/loaders.py
index 3b21faf..30b6017 100644
--- a/hshetl/loaders.py
+++ b/hshetl/loaders.py
@@ -132,6 +132,9 @@ class CsvLoader(AbstractLoader):
self.dialect = dialect
self._resolve_dialect()
+ def can_execute(self, connector):
+ '''Defines which connector can be handled by this extractor.'''
+ return isinstance(connector, FileConnector)
def _update(self, data = []):
'''This loader can not update records. Therefore only empty data is allowed'''
@@ -201,6 +204,10 @@ class SqlAlchemyLoader(AbstractLoader):
self.table_name = table_name
'''The name of the table where the records will be load.'''
+ def can_execute(self, connector):
+ '''Defines which connector can be handled by this extractor.'''
+ return isinstance(connector, SqlAlchemyConnector)
+
def _execute(self, result):
'''Executes the loading of data. Distinguishes between update, insert and delete'''
self.table = Table(self.table_name,
@@ -299,6 +306,10 @@ class LdapLoader(AbstractLoader):
self.objectClass = objectClass
'''The objectClass of new inserted records.'''
+ def can_execute(self, connector):
+ '''Defines which connector can be handled by this extractor.'''
+ return isinstance(connector, LdapConnector)
+
def _execute(self, result):
'''Executes the loading of data. Distinguishes between update, insert and delete.'''
logging.debug('Loads data: ' + self.__class__.__name__)
--
GitLab