Settings

class gpype.common.settings._Settings[source]

Bases: dict

Singleton settings manager for g.Pype application configuration.

Manages persistent settings stored in XML format in platform-specific directories. Provides automatic type conversion, default values, and thread-safe singleton access.

Storage locations: - Windows: %PROGRAMDATA%/gtec/gPype/settings.xml - macOS: ~/Library/Application Support/gtec/gPype/settings.xml - elsewhere: $XDG_CONFIG_HOME (or ~/.config)/gtec/gPype/settings.xml

Where that directory cannot be determined or created – Android, with no usable home – the temp directory’s gtec/gPype is used instead, and where that fails too the settings live in memory only (file_path is None). Either is announced once, with a RuntimeWarning naming the file used or saying the settings will not persist. An explicit GPYPE_SETTINGS_DIR is never replaced.

Use Settings.get() to access the singleton instance.

DEFAULTS = {'Key': ''}

Default settings applied on first initialization

__init__()[source]

Initialize the settings singleton instance.

Loads existing settings from XML file, applies default values for missing keys, and saves the updated configuration.

Raises:

RuntimeError – If an instance already exists. Use get() instead.

static get()[source]

Get the singleton settings instance.

Creates the instance if it doesn’t exist, otherwise returns the existing instance.

Returns:

The singleton settings instance.

Return type:

_Settings

write()[source]

Write current settings to the XML file with pretty formatting.

Does nothing where no directory could be created (file_path is None): the settings are then kept for this process only, as the warning given at construction said.