summaryrefslogtreecommitdiff
path: root/factories/INL_factory.py
diff options
context:
space:
mode:
Diffstat (limited to 'factories/INL_factory.py')
-rw-r--r--factories/INL_factory.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/factories/INL_factory.py b/factories/INL_factory.py
new file mode 100644
index 0000000..6607368
--- /dev/null
+++ b/factories/INL_factory.py
@@ -0,0 +1,23 @@
+import entities
+from factories import BasicFactory
+
+TAG_TO_ENTITY_MAPPING = {
+ '100': entities.Person,
+ '110': entities.Institution,
+ '151': entities.Location
+}
+
+
+class INLFactory(BasicFactory):
+ def __init__(self, tag_to_entity_mapping=None):
+ self.mapping = tag_to_entity_mapping or TAG_TO_ENTITY_MAPPING
+
+ def get_entity(self, entity_key, raw_object):
+ if entity_key == '100':
+ return entities.Person('', '', '')
+ elif entity_key == '110':
+ return entities.Institution()
+ elif entity_key == '151':
+ return entities.Location('', '', '')
+ else:
+ raise KeyError('Key {} was not recognized for factory {}'.format(entity_key, type(self)))