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.2.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for dypendence-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf0ed547d1863d5b36846fe515c223bbad5d65922352bd7a9f3c35af7be896f0 |
|
MD5 | 90421febb0b92b7c70b1b92210be00e0 |
|
BLAKE2b-256 | cd130b10d054368fd21929fbecb7f9d463439e7cefeccf28d633138b9d2e9477 |