tik_manager4.core.settings ========================== .. py:module:: tik_manager4.core.settings .. autoapi-nested-parse:: Module to handle settings data. Classes ------- .. autoapisummary:: tik_manager4.core.settings.Settings Module Contents --------------- .. py:class:: Settings(file_path=None) Generic Settings class to hold read and compare dictionary data. .. py:method:: add_missing_keys(data) Add only the non-existing keys, but do not update the existing ones. .. py:method:: 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. .. py:method:: 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. .. py:method:: copy_data() Return a copy of the current data. .. py:method:: delete_property(key) Delete the given property key. .. py:method:: 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. .. py:method:: 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. .. py:method:: 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. .. py:method:: get_data() Return the whole current data. .. py:method:: 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. .. py:method:: 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. .. py:method:: initialize(data) Initialize the settings data. Args: data (dict): The data to initialize the settings with. .. py:method:: is_modified() Check if the file has been modified since initialization. .. py:method:: is_settings_changed() Check if the settings changed since initialization. .. py:method:: reload() Reload the settings from file. .. py:method:: reset_settings() Revert back the unsaved changes to the original state. .. py:method:: set_data(data) Feed the raw data directly. Args: data (dict): The data to set. .. py:method:: 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. .. py:method:: 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. .. py:method:: use_fallback() Use the fallback file. .. py:property:: date_modified Return the date modified of the settings file. .. py:property:: keys Return all keys in the current data. .. py:property:: properties Return the current dictionary data. .. py:property:: settings_file Return the settings file path. .. py:property:: values Return all values in the current data.