Skip to content

polychron.Config Module

Config dataclass

A dataclass representing user configuration, loaded from yaml on disk.

projects_directory class-attribute instance-attribute

projects_directory: Path = home() / 'Documents' / 'polychron' / 'projects'

Path to the projects directory for the user

verbose class-attribute instance-attribute

verbose: bool = False

If verbose output is enabled or not

geometry class-attribute instance-attribute

geometry: str = '1920x1080'

The initial window geometry

__post_init__

__post_init__() -> None

Fixup member variables post initialisation

This ensures that environment variables and ~ have been expanded in the projects_directory

load

load(path: Path) -> None

Load values from the specified path on disk"

Parameters:

Name Type Description Default
path Path

The path to a yaml file where configuration should be loaded from.

required

save

save(path: Path) -> None

Save the on-disk representation of the application config to the specified path as yaml

Parameters:

Name Type Description Default
path Path

The path where the file should be saved

required
Note
  • this is not comment or order preserving
  • this will save default values to disk, rather than just mutated or loaded values, which is not ideal

from_default_filepath classmethod

from_default_filepath() -> Config

Construct a Config instance from the default configuration file path

Returns:

Type Description
Config

A Config instance, populated from the config file at the platform specific location

get_config

get_config() -> Config

Get the single 'global' Configuration object instance.

On first call, the instance will be initialised to a value from disk, based on the platform-specific default location.

Returns:

Type Description
Config

The single application wide Configuration object.

Note

This is not thread-safe.