module filehelper.anyfhelper
¶
Short summary¶
module pyquickhelper.filehelper.anyfhelper
Various helpers about files
Functions¶
function |
truncated documentation |
---|---|
Changes the status of all files inside a folder. |
|
Reads the content of a source, whether it is a url, a file, a stream or a string (in that case, it returns the string … |
Documentation¶
Various helpers about files
- pyquickhelper.filehelper.anyfhelper.change_file_status(folder, status=128, strict=False, include_folder=True)[source]¶
Changes the status of all files inside a folder.
- Parameters:
folder – folder or file
status – new status
strict – False, use
|=
, True, use=
include_folder – change the status of the folders as well
- Returns:
list of modified files
By default, status is
stat.S_IWRITE
. If folder is a file, the function changes the status of this file, otherwise, it will change the status of every file the folder contains.
- pyquickhelper.filehelper.anyfhelper.read_content_ufs(file_url_stream, encoding='utf8', asbytes=False, add_source=False, min_size=None)[source]¶
Reads the content of a source, whether it is a url, a file, a stream or a string (in that case, it returns the string itself), it assumes the content type is text.
- Parameters:
file_url_stream – file or url or stream or string
encoding – encoding
asbytes – return bytes instead of chars
add_source – also return the way the content was obtained
min_size – if not empty, the function raises an exception if the size is below that theshold
- Returns:
content of the source (str) or (content, type)
Type can be:
rb: binary file
r: text file
u: url
ub: binary content from url
s: string
b: binary string
S: StringIO
SB: BytesIO
SBb: BytesIO, return bytes
The function can return bytes.