diff options
author | roy lewin <roy.lewin@gmail.com> | 2016-09-21 21:59:22 +0300 |
---|---|---|
committer | roy lewin <roy.lewin@gmail.com> | 2016-09-21 21:59:22 +0300 |
commit | 985a0fcac8b89bfe3c5bdcea0889b921cc27c033 (patch) | |
tree | 8cc9bc1fbcae35a0aab8b49e3f04c3c0843e0fdd /factories/INL_factory.py | |
parent | 9876529cd25312ce1b92329618a81d962fb86c44 (diff) |
Added basic entities
Diffstat (limited to 'factories/INL_factory.py')
-rw-r--r-- | factories/INL_factory.py | 23 |
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))) |