file_utils ¶
File utilities for hot reload system.
Classes:
-
FileHashTracker–Tracks file hashes to detect changes.
Functions:
-
path_from_extension–Convert extension name to file path.
-
get_extension_from_path–Convert file path to extension name.
-
validate_python_syntax–Validate Python syntax of a file.
-
module_reload_context–Context manager for safe module reloading.
-
reload_module_by_name–Reload a module by name.
Classes¶
FileHashTracker ¶
FileHashTracker()
Tracks file hashes to detect changes.
Initialize the file hash tracker.
Methods:
-
get_file_hash–Get SHA-256 hash of file contents.
-
has_changed–Check if file has changed since last check.
-
update_hash–Update stored hash for a file.
-
clear–Clear all stored hashes.
-
remove_file–Remove file from tracking.
Functions¶
path_from_extension ¶
get_extension_from_path ¶
Convert file path to extension name.
Handles both flat and nested plugin structures: - src/tux/modules/admin/ban.py → tux.modules.admin.ban - src/tux/plugins/atl/deepfry.py → tux.plugins.atl.deepfry
Returns:
-
str | None–The extension name if found, None otherwise.
validate_python_syntax ¶
module_reload_context ¶
module_reload_context(module_name: str)
Context manager for safe module reloading.
reload_module_by_name ¶
Reload a module by name.
Returns:
-
bool–True if reload was successful.
Raises:
-
ModuleReloadError–If the module fails to reload.