Coverage for src/configuraptor/loaders/__init__.py: 100%

1"""

2 Loads loaders based on Python version.

3"""

4

5# tomli used for every Python version now.

6 from .loaders_shared import dotenv, ini, json, toml, yaml

7 from .register import LOADERS, T_loader, register_loader

8

9

10 def get(extension: str) -> T_loader:

11 """

12 Get the right loader for a specific extension.

13 """

14 extension = extension.removeprefix(".")

15

16 if loader := LOADERS.get(extension):

17 return loader

18 else:

19 raise ValueError(f"Invalid extension {extension}")

20

21

22 __all__ = ["get", "toml", "json", "yaml", "dotenv", "ini", "register_loader"]