FileHelper
Class containing only classmethod to simplify file management
TODO deprecated, to remove in v0.19.0 Return the extension of a file without the '.' if it is present on first caracter
strstrCopy a directory from source to destination
str | pathlib.Pathstr | pathlib.PathCopy the content of a directory to another directory
str | pathlib.Pathstr | pathlib.PathCopy a file from source to destination
str | pathlib.Pathstr | pathlib.PathCopy a file or a directory from source to destination
str | pathlib.Pathstr | pathlib.PathCreate a directory and all intermediate directories if they do not exist
str | pathlib.PathPathCreate an empty file if it does not exist. Creates intermediate directories if needed.
str | pathlib.PathPathCreate a FastAPI FileResponse from a file path
str | pathlib.PathstrstrLiteral - attachmentFileResponseDelete a directory and all its content
str | pathlib.Pathbool - TrueDelete all the content of a directory but not the directory itself.
str | pathlib.Pathbool - TrueDelete a file
str | pathlib.Pathbool - TrueDelete a file or a directory
str | pathlib.Pathbool - TrueDetect the encoding of a file using charset-normalizer.
str | pathlib.Pathstr - utf-8strExist on local machine
str | pathlib.PathReturn the parent directory of a file or a folder
str | pathlib.PathPathReturn the content of a directory as a json nested object.
str | pathlib.PathAnyReturn the name of the folder. If the path is a file, return the name of the parent folder. If the path is a folder, return the name of the folder.
str | pathlib.PathReturn the extension of a file from its content type
strstrReturn a human readable size from a size in bytes. Ex : 1024 -> 1 KB
floatstrstr | pathlib.PathstrReturn the name of the file without the extension or the name of the folder. For compound extensions like .tar.gz, removes all extension parts.
str | pathlib.PathstrReturn the name of the file with the extension or the name of the folder
str | pathlib.PathReturn the extension of a file without the '.' in lowercase. Return None if no extension is found (like folder). Special cases:
- .R extension is returned as uppercase 'R'
- Compound extensions like .tar.gz are returned as 'tar.gz'
str | pathlib.Pathstr | NoneReturn a Path object from a string or a Path object
str | pathlib.PathPathReturn the size of a file or a folder. For folder, it is the sum of the size of all files in the folder (recursive).
str | pathlib.Pathintstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.Pathboolstr | pathlib.PathboolMove a file or a directory from source to destination
str | pathlib.Pathstr | pathlib.PathNormalize a file extension by removing leading dots and applying case rules. Returns the extension in lowercase except for special cases (.R stays uppercase). Returns None if the input is None.
strstr | NoneSanitize a file name, folder name or path in order to prevent injection when using the file name Removes dangerous characters and prevents path traversal attacks Also normalizes file extensions (lowercase except for .R, handles .tar compounds)
strstrGenerate a unique fs node name for a list of node names. Append _1, _2... before the extension if the str is already in the list. Useful to avoid name collision when adding a file to a directory.
strstrstrGenerate a unique fs node name for a list of node names. Append _1, _2... before the extension if the str is already in the list. Useful to avoid name collision when adding a file to a directory.
liststrstr