Skip to content

The MinimalDetector class

The Minimaldetector 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.minimaldetector.MinimalDetector

MinimalDetector()

Bases: FormatDetector

Simple format detector using the Python mimetypes module.

This detector uses file extensions to determine the MIME type. It is not very reliable and should only be used if no other detector is available.

Initialize the MinimalDetector and register additional MIME types.

Notes
  • Adds support for .jp2, .webp, .jsonld, .md, .xml, and .csv extensions.

guess_file_type

guess_file_type(filepath)

Detect the format of a file using the mimetypes module.

PARAMETER DESCRIPTION
filepath

Path to the file to analyze.

TYPE: Path

RETURNS DESCRIPTION
FormatInfo

Object containing detected format information.

TYPE: FormatInfo

Notes
  • Uses DEFAULT_TYPE if MIME type cannot be determined.
  • Integrates with xmltypes and jsontypes for subtype detection.

looks_like_xml staticmethod

looks_like_xml(filepath)

Return True if the file looks like an XML file.

has_xml_declaration staticmethod

has_xml_declaration(filepath)

Return True if filepath contains an xml declaration.