Skip to content

The SiegfriedDetector class

This is the suggested and default Detector Class.

Usage:

from gamslib.formatdetect.siegfrieddetector import Siegfriedetector as Detector

detector = Detector()
format = detector.guess_file_type('foo/bar.xml')

gamslib.formatdetect.SiegfriedDetector

SiegfriedDetector()

Bases: FormatDetector

Detector that uses the Pygfried library to detect file formats.

Uses Siegfried's prediction engine to identify file types and MIME types.

Initialize the SiegfriedDetector.

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.

guess_file_type

guess_file_type(filepath)

Detect the format of a file using Pygfried and return a FormatInfo object.

PARAMETER DESCRIPTION
filepath

Path to the file to be analyzed.

TYPE: Path

RETURNS DESCRIPTION
FormatInfo

An object containing the detected format information.

TYPE: FormatInfo