-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_source.py
53 lines (43 loc) · 1.44 KB
/
data_source.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from abc import ABCMeta, abstractmethod
class DataSource(object):
__metaclass__ = ABCMeta
@abstractmethod
def connect(self):
"""Vyrobi novy connection objekt pre dany data source, ak by nahodou bolo
treba rozne connection v roznych threadoch, malo by to vzdy vracat novu
(alebo nepouzivanu poolovanu) instanciu
"""
raise NotImplemented
def __call__(self):
return self.connect()
class DataSourceConnection(object):
__metaclass__ = ABCMeta
@abstractmethod
def search_by_author(self, surname, name=None, year=None):
"""Vrati iterator vracajuci zoznam publikacii pre dane meno a rok
- priezvisko hlada presne
- meno hlada ako prefix (t.j. T najde aj Tomas)
- ak je rok zadany, vracia len zaznamy pre dany rok, inak pre vsetky roky
"""
raise NotImplemented
@abstractmethod
def search_citations(self, publications):
"""Vrati iterator vracajuci zoznam publikacii, ktore cituju publikacie
v zozname publications
"""
raise NotImplemented
@abstractmethod
def assign_indexes(self, publications):
"""Zisti a nastavi, v akych indexoch sa publikacie nachadzaju
"""
raise NotImplemented
@abstractmethod
def close(self):
"""Uvolni zdroje pouzivane tymto objektom"""
raise NotImplemented
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.close()
return False