tik_manager4.core.settings

Module to handle settings data.

Classes

Settings

Generic Settings class to hold read and compare dictionary data.

Module Contents

class Settings(file_path=None)

Generic Settings class to hold read and compare dictionary data.

add_missing_keys(data)

Add only the non-existing keys, but do not update the existing ones.

add_property(key, val, force=True)

Create a property key with given value.

Args:

key (str): The property key to create. val (any): The value to assign to the key. force (bool): Whether to force create the key or not.

Returns:

bool: True if the key was created, False otherwise.

apply_settings(force=False)

Apply the changed settings and writes it to file.

Args:

force (bool): Whether to force write the settings or not.

Returns:

bool: True if the settings were written to file, False otherwise.

copy_data()

Return a copy of the current data.

delete_property(key)

Delete the given property key.

edit_property(key, val)

Update the property key with given value.

Args:

key (str): The property key to update. val (any): The value to update the key with.

edit_sub_property(sub_keys, new_val)

Edit nested properties.

Args:

sub_keys (list): The list of keys to traverse the nested properties. new_val (any): The new value to assign to the final key.

get(key, default=None)

Duplicate of get_property for situations where it may be present with dict items.

Args:

key (str): The key to get the value of. default (any): The default value to return if the key is not found.

get_data()

Return the whole current data.

get_property(key, default=None)

Return the value of the property key.

Args:

key (str): The key to get the value of. default (any): The default value to return if the key is not found.

Returns:

any: The value of the key.

get_sub_property(sub_keys)

Return the value of the sub property key.

Args:

sub_keys (list): The list of keys to traverse the nested properties.

Returns:

any: The value of the final key.

initialize(data)

Initialize the settings data.

Args:

data (dict): The data to initialize the settings with.

is_modified()

Check if the file has been modified since initialization.

is_settings_changed()

Check if the settings changed since initialization.

reload()

Reload the settings from file.

reset_settings()

Revert back the unsaved changes to the original state.

set_data(data)

Feed the raw data directly.

Args:

data (dict): The data to set.

set_fallback(file_path)

Use the given file in case the file_path is not found.

Args:

file_path (str): The file path to use as fallback.

update(data, add_missing_keys=False)

Update the settings data.

Args:

data (dict): The data to update the settings with. add_missing_keys (bool): Whether to add missing keys or not.

use_fallback()

Use the fallback file.

property date_modified
Return the date modified of the settings file.
property keys
Return all keys in the current data.
property properties
Return the current dictionary data.
property settings_file
Return the settings file path.
property values
Return all values in the current data.