sleap.io.format.adaptor#

File format adaptor base class.

class sleap.io.format.adaptor.Adaptor[source]#

File format adaptor base class.

An adaptor handles reading and/or writing a specific file format. To add support for a new file format, you’ll create a new class which inherits from the Adaptor base class and implements the relevant functions.

property all_exts: List[str]#

List of all file extensions supported by adaptor.

can_read_file(file: sleap.io.format.filehandle.FileHandle) bool[source]#

Returns whether this adaptor can read this file.

can_write_filename(filename: str) bool[source]#

Returns whether this adaptor can write format of this filename.

property default_ext: str#

The default file extension, e.g., ‘json’ (without ‘.’).

does_match_ext(filename: str) bool[source]#

Returns whether this adaptor can write format of this filename.

does_read() bool[source]#

Returns whether this adaptor supports reading.

does_write() bool[source]#

Returns whether this adaptor supports writing.

property formatted_ext_options#

String for Qt file dialog extension options.

property handles: sleap.io.format.adaptor.SleapObjectType#

Returns the type of object that can be read/written.

The Dispatch class calls this method on all registered adaptors to determine which to use for reading/writing.

property name: str#

Human-reading name of the file format

read(file: sleap.io.format.filehandle.FileHandle) object[source]#

Reads the file and returns the appropriate deserialized object.

write(filename: str, source_object: object)[source]#

Writes the object to a file.

class sleap.io.format.adaptor.SleapObjectType(value)[source]#

Types of files that an adaptor could read/write.