33 lines
483 B
Python
33 lines
483 B
Python
import json
|
|
|
|
|
|
class Loader:
|
|
def load(self, file: str):
|
|
raise NotImplementedError()
|
|
|
|
def get_entry(self) -> object:
|
|
raise NotImplementedError()
|
|
|
|
|
|
class JSONLoader(Loader):
|
|
data = None
|
|
|
|
def load(self, file: str):
|
|
self.data = json.load(open(file))
|
|
|
|
def get_entry(self):
|
|
for entry in self.data:
|
|
yield entry
|
|
|
|
class SQLiteLoader(Loader):
|
|
def load(self, file: str):
|
|
pass
|
|
|
|
def get_entry(self) -> object:
|
|
pass
|
|
|
|
|
|
LOADERS = {
|
|
"json": JSONLoader,
|
|
"sqlite": SQLiteLoader
|
|
} |