config
dev_tool.config
__all__ = ['ConfigManager', 'ContainerPathDefault', 'DatabaseDefault', 'DevelopmentDefault', 'DockerConfig', 'DockerContainerDefault', 'DockerDefault', 'DockerFileDefault', 'DockerImageDefault', 'EnvConfig', 'FilesystemConfig', 'PyprojectConfig']
module-attribute
ContainerPathDefault
Default paths inside containers.
APP_ROOT = '/app'
class-attribute
instance-attribute
PARALLEL_ROOT = '/parallel'
class-attribute
instance-attribute
POSTGRES_DATA = '/var/lib/postgresql/data'
class-attribute
instance-attribute
DatabaseDefault
Default values for database configuration (generic PostgreSQL).
ENGINE = 'postgresql'
class-attribute
instance-attribute
HOST = 'localhost'
class-attribute
instance-attribute
NAME = 'postgres'
class-attribute
instance-attribute
PASSWORD = 'postgres'
class-attribute
instance-attribute
PORT = '5432'
class-attribute
instance-attribute
USER = 'postgres'
class-attribute
instance-attribute
DevelopmentDefault
Default values for local development environment.
DATABASE_NAME = 'stratus'
class-attribute
instance-attribute
DATABASE_PASSWORD = 'stratus'
class-attribute
instance-attribute
DATABASE_PORT = '5432'
class-attribute
instance-attribute
DATABASE_USER = 'stratus'
class-attribute
instance-attribute
DockerContainerDefault
Default Docker container naming conventions.
APP_SUFFIX = '-app'
class-attribute
instance-attribute
DB_SUFFIX = '-db'
class-attribute
instance-attribute
DockerDefault
Default values for Docker configuration.
APP_PORT = 8000
class-attribute
instance-attribute
CONTAINER_PORT = 5432
class-attribute
instance-attribute
CONTAINER_SIZE = '8g'
class-attribute
instance-attribute
POSTGRES_VERSION = '14'
class-attribute
instance-attribute
SSH_PORT = 2222
class-attribute
instance-attribute
DockerFileDefault
Default Dockerfile and compose file names.
APP = 'Dockerfile.app'
class-attribute
instance-attribute
COMPOSE = 'docker-compose.yml'
class-attribute
instance-attribute
DB = 'Dockerfile.db'
class-attribute
instance-attribute
DockerImageDefault
Default Docker image names and tags.
APP = 'stratus:shared-app'
class-attribute
instance-attribute
CUSTOM = 'stratus:shared'
class-attribute
instance-attribute
DB = 'stratus:shared-db'
class-attribute
instance-attribute
DockerConfig
A class for managing Docker configuration settings.
This class provides methods for creating default Docker configurations based on environment variables and user settings.
The constructor for the DockerConfig class.
Source code in dev_tool/config/docker.py
create_default_docker_config
A method that creates a default Docker configuration dictionary.
This method combines user-provided configuration with environment variables to create a complete Docker container configuration.
Parameters:
-
container_name(str) –The name to use for the Docker container.
-
docker_config(dict) –The user-provided Docker configuration dictionary.
Returns:
-
dict–A complete Docker configuration dictionary.
Source code in dev_tool/config/docker.py
get_dockerfile_path
Get the Dockerfile path - project Dockerfile takes precedence over default.
Returns:
-
Path | None–Path to Dockerfile to use, or None if using standard postgres image
Source code in dev_tool/config/docker.py
set_notification
A method that sets the notification service.
Parameters:
-
notification(NotificationProtocol) –The notification service to use.
set_resource_path_getter
A method that sets the resource path getter function.
Parameters:
Source code in dev_tool/config/docker.py
should_build_custom_image
EnvConfig
A class for managing environment configuration.
This class provides methods for loading, reloading, and creating default environment variable configurations.
create_default_env
A method that creates a default environment file.
This method copies the content from a template file to create a new environment configuration file if it doesn't already exist.
Parameters:
-
path(Path) –The path where the new environment file should be created.
-
template(Path) –The path to the template environment file.
Source code in dev_tool/config/env.py
get_docker_authorization
A method that retrieves Docker authorization credentials.
This method gets the username and password for Docker from environment variables, falling back to default values if not set.
Returns:
Raises:
-
OSError–If the username or password is empty.
Source code in dev_tool/config/env.py
reload
A method that reloads environment variables from a .env file.
This method loads environment variables from the specified file path, overriding any existing variables with the same names.
Parameters:
-
dotenv_path(Path | str | None, default:None) –The path to the .env file to load.
-
prompt(bool, default:False) –Whether to prompt the user for the env file path.
Source code in dev_tool/config/env.py
FilesystemConfig
A class for handling filesystem operations for configuration.
This class provides methods for resolving paths and reading configuration files.
get_resource_path
A method that resolves a resource path.
This method handles both packaged (frozen) and development environments by resolving the appropriate absolute path to a resource.
Parameters:
-
path(str) –The relative path to the resource.
Returns:
-
Path–The absolute Path to the resource.
Source code in dev_tool/config/filesystem.py
get_developer_token
A method that retrieves a developer token from a file.
This method reads a token from the specified file, stripping any whitespace.
Parameters:
-
path(Path) –The path to the file containing the token.
Returns:
-
str | None–The token as a string, or None if the file doesn't exist.
Source code in dev_tool/config/filesystem.py
ConfigManager
A singleton class for managing configuration across the application.
This class handles loading, reloading, and providing access to various configuration settings from different sources.
A constructor for the ConfigManager class.
This method initializes all configuration components and sets up file watching if a watcher is provided.
Parameters:
-
watcher(FileWatcherService | None, default:None) –An optional file watcher service for monitoring config changes.
Source code in dev_tool/config/manager.py
docker = DockerConfig()
instance-attribute
env = EnvConfig()
instance-attribute
fs = FilesystemConfig()
instance-attribute
pyproject = PyprojectConfig()
instance-attribute
__new__
The method that implements the singleton pattern.
This method ensures only one instance of ConfigManager exists.
Returns:
-
Self–The singleton ConfigManager instance.
Source code in dev_tool/config/manager.py
set_notification
classmethod
A class method that sets the notification service for the config manager.
Parameters:
-
notification(NotificationProtocol) –The notification service to use.
Source code in dev_tool/config/manager.py
create_default_docker_config
A method that creates a default Docker configuration.
This method generates a complete Docker configuration using the project name and user-provided Docker configuration.
Returns:
Source code in dev_tool/config/manager.py
get_bun_config
A method that retrieves the Bun configuration.
This method gets the Bun configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_coverage_config
A method that retrieves the coverage configuration.
This method gets the coverage configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_current_version
A method that retrieves the current version.
This method returns the current version of the application.
Returns:
-
str–The version string.
get_dev_tool_config
A method that retrieves the dev_tool configuration.
This method gets the dev_tool configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_dev_tool_port
A method that retrieves the dev_tool port setting.
This method gets the port number configured for the dev_tool.
Returns:
-
str | None–The port string, or None if not configured.
Source code in dev_tool/config/manager.py
get_developer_token
A method that retrieves the developer token.
This method gets the developer token from the token file.
Returns:
-
str | None–The developer token string, or None if not available.
Source code in dev_tool/config/manager.py
get_django_config
A method that retrieves the Django configuration.
This method gets the Django configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_django_coverage_config
A method that retrieves the Django coverage configuration.
This method gets the Django coverage configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_django_unittest_config
A method that retrieves the Django unit test configuration.
This method gets the Django unit test configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_docker_authorization
A method that retrieves Docker authorization credentials.
This method gets the username and password for Docker from environment variables.
Returns:
Source code in dev_tool/config/manager.py
get_docker_config
A method that retrieves the Docker configuration.
This method gets the Docker configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_project_config
A method that retrieves a project configuration section.
This method gets a specific section from the project configuration.
Parameters:
-
key(str) –The section key to retrieve.
Returns:
Source code in dev_tool/config/manager.py
get_project_name
A method that retrieves the project name.
This method gets the project name from the pyproject.toml file.
Returns:
-
str–The project name string.
Source code in dev_tool/config/manager.py
get_python_coverage_config
A method that retrieves the Python coverage configuration.
This method gets the Python coverage configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_python_unittest_config
A method that retrieves the Python unittest configuration.
This method gets the Python unittest configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_resource_path
get_scripting_config
A method that retrieves the scripting configuration.
This method gets the scripting configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_tool_config
A method that retrieves a tool configuration section.
This method gets a specific section from the tool configuration.
Parameters:
-
key(str) –The section key to retrieve.
Returns:
Source code in dev_tool/config/manager.py
get_unittest_config
A method that retrieves the unittest configuration.
This method gets the unittest configuration section.
Returns:
Source code in dev_tool/config/manager.py
get_version
initialize_watcher
A method that initializes the file watcher.
This method sets up file watching for configuration files with the specified polling interval.
Parameters:
-
interval(float, default:1.0) –The polling interval in seconds.
Source code in dev_tool/config/manager.py
register_listener
A method that registers a callback for configuration change events.
Parameters:
-
event(ConfigEvent) –The configuration event to listen for.
-
callback(Callable) –The callback function to invoke when the event occurs.
Source code in dev_tool/config/manager.py
reload_all
A method that reloads all configuration files.
This method refreshes both environment and pyproject configurations.
reload_env
A method that reloads environment variables.
This method refreshes environment variables from the .env file.
reload_pyproject
A method that reloads the pyproject.toml configuration.
This method refreshes configuration from the pyproject.toml file.
start_watching
A method that starts the file watcher.
This method begins monitoring configuration files for changes.
Source code in dev_tool/config/manager.py
stop_watching
A method that stops the file watcher.
This method ends monitoring of configuration files.
unregister_listener
A method that unregisters a callback for configuration change events.
Parameters:
-
event(ConfigEvent) –The configuration event to stop listening for.
-
callback(Callable) –The callback function to remove.
Source code in dev_tool/config/manager.py
validate_configuration
A method that validates that required configuration files exist.
This method emits warnings for any missing configuration files.
Source code in dev_tool/config/manager.py
PyprojectConfig
A class for managing pyproject.toml configuration.
This class provides methods for loading, parsing, and retrieving settings from the pyproject.toml file.
The constructor for the PyprojectConfig class.
This method initializes an empty configuration dictionary.
Source code in dev_tool/config/pyproject.py
create_default
A method that creates a default pyproject.toml file.
This method copies the content from a template file to create a new pyproject.toml file if it doesn't already exist.
Parameters:
-
path(Path) –The path where the new file should be created.
-
template(Path) –The path to the template file.
Source code in dev_tool/config/pyproject.py
get_bun_config
A method that retrieves the Bun configuration.
This method gets the Bun configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_coverage_config
A method that retrieves the coverage configuration.
This method gets the coverage configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_dev_tool_config
A method that retrieves the dev_tool configuration.
This method gets the entire dev_tool configuration section.
Returns:
Source code in dev_tool/config/pyproject.py
get_dev_tool_port
A method that retrieves the dev_tool port setting.
This method gets the port number configured for the dev_tool.
Returns:
-
str | None–The port string, or None if not configured.
Source code in dev_tool/config/pyproject.py
get_django_config
A method that retrieves the Django configuration.
This method gets the Django configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_django_coverage_config
A method that retrieves the Django coverage configuration.
This method gets the Django-specific coverage configuration and merges it with the base.
Returns:
Source code in dev_tool/config/pyproject.py
get_django_unittest_config
A method that retrieves the Django unittest configuration.
This method gets the Django-specific unittest configuration and merges it with the base.
Returns:
Source code in dev_tool/config/pyproject.py
get_docker_config
A method that retrieves the Docker configuration.
This method gets the Docker configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_project_config
A method that retrieves a project configuration section.
This method gets a specific section from the project configuration.
Parameters:
-
key(str) –The section key to retrieve.
Returns:
Source code in dev_tool/config/pyproject.py
get_project_name
A method that retrieves the project name.
This method gets the project name from the configuration.
Returns:
-
str–The project name, or 'project' if not specified.
Source code in dev_tool/config/pyproject.py
get_python_coverage_config
A method that retrieves the Python coverage configuration.
This method gets the Python-specific coverage configuration and merges it with the base.
Returns:
Source code in dev_tool/config/pyproject.py
get_python_unittest_config
A method that retrieves the Python unittest configuration.
This method gets the Python-specific unittest configuration and merges it with the base.
Returns:
Source code in dev_tool/config/pyproject.py
get_scripting_config
A method that retrieves the scripting configuration.
This method gets the scripting configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_tool_config
A method that retrieves a tool configuration section.
This method gets a specific section from the tool configuration.
Parameters:
-
key(str) –The section key to retrieve.
Returns:
Source code in dev_tool/config/pyproject.py
get_unittest_config
A method that retrieves the unittest configuration.
This method gets the unittest configuration section from dev_tool config.
Returns:
Source code in dev_tool/config/pyproject.py
get_value
A method that retrieves a value from the pyproject.toml configuration.
This method traverses the configuration using the provided keys and returns the default value if the path doesn't exist.
Parameters:
-
keys(str, default:()) –The sequence of keys to navigate through.
-
default(Any, default:None) –The default value to return if the path doesn't exist.
Returns:
-
Any–The value at the specified path, or the default.
Source code in dev_tool/config/pyproject.py
reload
A method that reloads the pyproject.toml configuration.
This method reads the configuration from the specified file path and updates the internal configuration dictionary.
Parameters:
-
path(Path) –The path to the pyproject.toml file.
Source code in dev_tool/config/pyproject.py
set_notification
A method that sets the notification service.
Parameters:
-
notification(NotificationProtocol) –The notification service to use.