ContextMixin¶
Provides context manager functionality.
Methods¶
enter¶
Enter the context manager and load the file.
Returns:
- Self: The file manager instance
Example:
with YAPFileManager("config.json") as fm:
# File is automatically loaded
fm.set_key("value", dot_key="key")
exit¶
Exit the context manager and save if dirty.
Parameters:
- exc_type: Exception type
- exc_val: Exception value
- exc_tb: Exception traceback
Example:
with YAPFileManager("config.json") as fm:
fm.set_key("value", dot_key="key")
# File is automatically saved when exiting context
lazy_save¶
Context manager for lazy saving.
Parameters:
- save_on_exit (bool): Whether to save when exiting the context. Default: True
Returns:
- Iterator[Self]: The file manager instance
Example:
with fm.lazy_save():
fm.set_key("value1", dot_key="key1")
fm.set_key("value2", dot_key="key2")
# Save happens here when exiting lazy_save context
auto_save¶
Context manager for automatic saving.
Parameters:
- save_on_exit (bool): Whether to save when exiting the context. Default: True
Returns:
- Iterator[Self]: The file manager instance
Example: