test if a source is loaded
This commit is contained in:
parent
8dca850683
commit
8e0fe77274
|
@ -98,10 +98,12 @@ class TiramisuController(Controller):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
test: bool,
|
test: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
self.source_imported = None
|
||||||
if not 'dataset_name' in vars(self):
|
if not 'dataset_name' in vars(self):
|
||||||
raise Exception(f'please specify "dataset_name" to "{self.__class__.__name__}"')
|
raise Exception(f'please specify "dataset_name" to "{self.__class__.__name__}"')
|
||||||
self.tiramisu_cache_root_path = join(get_config()['cache']['root_path'], self.dataset_name)
|
self.tiramisu_cache_root_path = join(get_config()['cache']['root_path'], self.dataset_name)
|
||||||
super().__init__(test)
|
super().__init__(test)
|
||||||
|
self.internal_source_name = get_config()['servermodel']['internal_source']
|
||||||
if not test:
|
if not test:
|
||||||
db_conf = get_config()['database']['tiramisu_dsn']
|
db_conf = get_config()['database']['tiramisu_dsn']
|
||||||
self.save_storage = Storage(engine='postgres')
|
self.save_storage = Storage(engine='postgres')
|
||||||
|
@ -130,6 +132,12 @@ class TiramisuController(Controller):
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
) -> None:
|
) -> None:
|
||||||
sources = await self.get_sources(risotto_context)
|
sources = await self.get_sources(risotto_context)
|
||||||
|
source_imported = sources != [self.internal_source_name]
|
||||||
|
if source_imported and self.source_imported is False:
|
||||||
|
await self.load_datas(risotto_context)
|
||||||
|
self.source_imported = source_imported
|
||||||
|
if not self.source_imported:
|
||||||
|
return
|
||||||
self._aggregate_tiramisu_funcs(sources)
|
self._aggregate_tiramisu_funcs(sources)
|
||||||
self._convert_dictionaries_to_tiramisu(sources)
|
self._convert_dictionaries_to_tiramisu(sources)
|
||||||
|
|
||||||
|
@ -175,7 +183,9 @@ except:
|
||||||
funcs.write(fh.read())
|
funcs.write(fh.read())
|
||||||
funcs.write(b'\n')
|
funcs.write(b'\n')
|
||||||
|
|
||||||
def _convert_dictionaries_to_tiramisu(self, sources: list) -> None:
|
def _convert_dictionaries_to_tiramisu(self,
|
||||||
|
sources: list,
|
||||||
|
) -> None:
|
||||||
funcs_file = join(self.tiramisu_cache_root_path, 'funcs.py')
|
funcs_file = join(self.tiramisu_cache_root_path, 'funcs.py')
|
||||||
tiramisu_file = join(self.tiramisu_cache_root_path, 'tiramisu.py')
|
tiramisu_file = join(self.tiramisu_cache_root_path, 'tiramisu.py')
|
||||||
dictionaries_dir = join(self.tiramisu_cache_root_path, 'dictionaries')
|
dictionaries_dir = join(self.tiramisu_cache_root_path, 'dictionaries')
|
||||||
|
|
Loading…
Reference in New Issue