chunklet.common.path_utils
Functions:
-
is_path_like–Check if a string looks like a filesystem path (file or folder),
-
read_text_file–Read text file with automatic encoding detection.
is_path_like
Check if a string looks like a filesystem path (file or folder), including Unix/Windows paths, hidden files, and scripts without extensions.
Parameters:
-
(textstr) –text to check.
Returns:
-
bool(bool) –True if string appears to be a filesystem path.
Examples:
>>> is_path_like("/home/user/document.txt")
True
>>> is_path_like("C:\Users\User\file.pdf")
True
>>> is_path_like("folder/subfolder/script.sh")
True
>>> is_path_like(".hidden_file")
True
>>> is_path_like("no_extension_script")
True
>>> is_path_like("path/with/newline\nchar")
False
>>> is_path_like("string_with_null_byte\x00")
False
Source code in src/chunklet/common/path_utils.py
read_text_file
Read text file with automatic encoding detection.
Parameters:
-
(pathstr | Path) –File path to read.
Returns:
-
str(str) –File content.
Raises:
-
FileProcessingError–If file cannot be read.