Coverage for whole_app/dictionaries/__init__.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-21 23:45 +0000

1import typing 

2 

3import structlog 

4 

5from . import dummy as dummy_storage 

6from . import file as file_storage 

7from . import protocol 

8from whole_app.settings import SETTINGS, StorageProviders 

9 

10 

11LOGGER_OBJ: typing.Final = structlog.get_logger() 

12 

13 

14def init_storage() -> None: 

15 if SETTINGS.dictionaries_storage_provider == StorageProviders.FILE: 

16 file_storage.init_storage() 

17 elif SETTINGS.dictionaries_storage_provider == StorageProviders.DUMMY: 

18 LOGGER_OBJ.warning( 

19 "Storage provider set to dummy mode. " 

20 "Currently all user dictionary requests will be thrown away. We worn you.", 

21 ) 

22 

23 

24def prepare_storage_engine() -> protocol.UserDictProtocol: 

25 if SETTINGS.dictionaries_storage_provider == StorageProviders.FILE: 

26 return file_storage.FileProvider() 

27 return dummy_storage.DummyProvider()