import os
from common_func.path_manager import PathManager
from common_func.singleton import singleton
from common_func.db_name_constant import DBNameConstant
from msmodel.compact_info.stream_expand_spec_model import StreamExpandSpecViewModel
@singleton
class StreamExpandSpecReader:
"""
class used to read stream expand spec data from stream_expand_spec.db
"""
def __init__(self: any) -> None:
self._stream_expand_spec = 0
self._is_load_stream_expand = False
@property
def is_stream_expand(self: any) -> bool:
return self._stream_expand_spec == 1
def load_stream_expand_spec(self: any, result_path: str) -> None:
"""
load stream expand spec
"""
if (not os.path.exists(PathManager.get_db_path(result_path, DBNameConstant.DB_STREAM_EXPAND_SPEC))
or self._is_load_stream_expand):
return
with StreamExpandSpecViewModel(result_path) as stream_expand_spec_model:
data = stream_expand_spec_model.get_stream_expand_spec_data()
if not data:
return
self._stream_expand_spec = data[0][0]
self._is_load_stream_expand = True