file_type_guesser.core
- file_type_guesser.core.check_if_text(stream, sample_size)
Check whether a stream is a plain-text file
- param stream
The stream
- param sample_size
the sample size that is checked
- return
Whether stream is plain-text
- Parameters
stream (_io.BufferedReader) –
sample_size (int) –
- Return type
bool
- file_type_guesser.core.check_signature_match(stream, file_info)
Check whether a stream matches given signatures
- param stream
The stream
- param file_info
The files info to match to
- return
Whether it matched
- Parameters
stream (_io.BufferedReader) –
file_info (file_type_guesser.types.FileInfo) –
- Return type
bool
- file_type_guesser.core.find_file_info(ext)
Get the extention and file type info for the given extention
- param ext
The files extention
- return
the recognised extention and file type info
- Parameters
ext (str) –
- Return type
tuple[str, file_type_guesser.types.FileInfo]
- file_type_guesser.core.guess(file_path, stream=None)
Make a guess with given file, using given stream for content if provided
- param file_path
The filepath of stream
- param stream
A stream to use, defaults to None
- return
The content guess
- Parameters
file_path (pathlib.Path | str) –
stream (Optional[_io.BufferedReader]) –
- Return type
- file_type_guesser.core.guess_file(file_path)
Make a guess of file type with given file path
- param file_path
The filepath of file
- return
The content guess
- Parameters
file_path (pathlib.Path) –
- Return type
- file_type_guesser.core.guess_stream(file_path, stream)
Make a guess with given file, using given stream for content
- param file_path
The filepath of stream
- param stream
A stream to use
- return
The content guess
- Parameters
file_path (pathlib.Path) –
stream (_io.BufferedReader) –
- Return type