tatami.config module¶
- class tatami.config.Config(*, app_name='Tatami', version='0.0.0', database=False)[source]¶
Bases:
BaseModel
- Parameters:
app_name (str)
version (str)
database (bool | str | DatabaseConfig)
- app_name: str¶
- database: bool | str | DatabaseConfig¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- version: str¶
- exception tatami.config.ConfigConflictError[source]¶
Bases:
ConfigError
- class tatami.config.DatabaseConfig(*, db_type='sqlite', driver=None, connection_string='sqlite:///tatami.db')[source]¶
Bases:
BaseModel
- Parameters:
db_type (Literal['postgres', 'postgresql', 'sqlite'])
driver (Literal['psycopg'] | None)
connection_string (str)
- connection_string: str¶
- db_type: Literal['postgres', 'postgresql', 'sqlite']¶
- driver: Literal['psycopg'] | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- exception tatami.config.InvalidFileError[source]¶
Bases:
ConfigError
- exception tatami.config.MissingEnvVarError[source]¶
Bases:
ConfigError
- tatami.config.find_config(project_path, mode=None)[source]¶
Find the configuration file for the given project
- Parameters:
project_path (str) – Path to the project
mode (Optional[str]) – The config mode (dev, prod, test…). If None the default config will be looked for. Defaults to None.
- Returns:
The path to the config if found, None if no config file was found
- Return type:
Optional[str]
- tatami.config.load_config(path)[source]¶
Load a config file
- Parameters:
path (str) – Path to the config file
- Returns:
The config object
- Return type:
- tatami.config.load_dotenv_files(path)[source]¶
Load all the dotenv (.env) files found in a given directory. Files whose name starts with an underscore will be excluded.
This function is internally used by Tatami to load all the files on the project directory
Example usage
Supposing we have three files
path/to/project/secrets.env
path/to/project/_ignore.env
path/to/project/.env
Calling the function .. code-block:: python
load_dotenv_files(‘path/to/project’)
would load the values found at
path/to/project/secrets.env
andpath/to/project/.env
but would ignore the values atpath/to/project/_ignore.env
as it starts with an underscore- Parameters:
path (str) – The path where the files will be searched
- Return type:
None