The MagikaDetector class¶
The Magikattector is a deprectated Implementation of the abstract FormatDetector class and should not be used anymore.
It will be removed in a later version.
gamslib.formatdetect.magikadetector.MagikaDetector
¶
Bases: FormatDetector
Detector that uses the Google Magika library to detect file formats.
Uses Magika's prediction engine to identify file types and MIME types. Applies corrections for known misclassifications (e.g., JSON-LD as JavaScript).
Initialize the MagikaDetector with Magika's BEST_GUESS prediction mode.
guess_file_type
¶
Detect the format of a file using Magika and return a FormatInfo object.
| PARAMETER | DESCRIPTION |
|---|---|
filepath
|
Path to the file to analyze.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FormatInfo
|
Object containing detected format information.
TYPE:
|
Notes
- Applies corrections for known Magika misclassifications.
- Uses DEFAULT_TYPE if Magika cannot determine the MIME type.
- Integrates with xmltypes and jsontypes for subtype detection.
looks_like_xml
staticmethod
¶
Return True if the file looks like an XML file.
has_xml_declaration
staticmethod
¶
Return True if filepath contains an xml declaration.