Dependency Injection over Dynaconf
Project description
Dypendence
Dependency Injection over Dynaconf
Usage example
Example settings.toml
[DY.FileStorageService]
Type = "S3FileStorage"
[DY.FileStorageService.LocalFileStorage]
some_value = "This is Local File Storage"
[DY.FileStorageService.S3FileStorage]
some_value = "This is S3 File Storage"
Example application code:
from dypendence import DY
class FileStorageService(DY):
def save_file(self) -> str:
raise NotImplementedError
def get_value_from_settings(self):
return self.settings.some_value
class LocalFileStorage(FileStorageService):
def save_file(self) -> str:
return 'Saved file to local file system'
class S3FileStorage(FileStorageService):
def save_file(self) -> str:
return 'Saved file to S3-like storage'
if __name__ == '__main__':
file_storage = FileStorageService(settings_files=['settings.toml'])
assert isinstance(file_storage, S3FileStorage)
assert file_storage.save_file() == 'Saved file to S3-like storage'
assert file_storage.get_value_from_settings() == 'This is S3 File Storage'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dypendence-0.1.6.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for dypendence-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577178fd56346d660201fa2d0d30a906f5a53dde891d75d5b869961875550f95 |
|
MD5 | 2a7393a0f750d0b96de3857e1aa793ec |
|
BLAKE2b-256 | 75ee6f6ea3e1205d853a6c843e40c792e673005ac810f5024458cf9a24ce72f5 |