Property List Manager#
- class PropertyListManager[source]#
Handles reading, writing, and managing configuration stored in Patcher’s property list file (
self.plist_path
).A
PatcherError
will be raised in the event of directory creation failure or if an error occurs trying to write information to the property list.- needs_migration() bool [source]#
Determines whether the plist file needs to be migrated.
- Returns:
True if old format is detected, False otherwise.
- Return type:
- migrate_plist() None [source]#
Modifies existing property list files in v1 format to v2 format.
A backup file is created in the event migration fails so user settings are perserved.
- Return type:
None
- get(section: str, key: str | None = None) Dict[str, Any] | Any | None [source]#
Retrieves a value from the property list file.
If a key is provided, its value will be returned. Otherwise, the section will be returned.
- set(key: str, value: Any, migration: bool = False) None [source]#
Sets a key-value pair or replaces a section in the property list file.
If
value
is a dictionary and the existing key is also a dictionary, it merges them.If
value
is a dictionary and the existing key is a primitive, it raises an error (unlessmigration=True
).If
value
is a primitive and the existing key is a dictionary, it raises an error (unlessmigration=True
).Otherwise, it stores the value as a top-level key.