adaptor
sleap.io.format.adaptor
¶
File format adaptor base class.
Classes:
| Name | Description |
|---|---|
Adaptor |
File format adaptor base class. |
SleapObjectType |
Types of files that an adaptor could read/write. |
Adaptor
¶
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.
Methods:
| Name | Description |
|---|---|
can_read_file |
Returns whether this adaptor can read this file. |
can_write_filename |
Returns whether this adaptor can write format of this filename. |
does_match_ext |
Returns whether this adaptor can write format of this filename. |
does_read |
Returns whether this adaptor supports reading. |
does_write |
Returns whether this adaptor supports writing. |
read |
Reads the file and returns the appropriate deserialized object. |
write |
Writes the object to a file. |
Attributes:
| Name | Type | Description |
|---|---|---|
all_exts |
List[str]
|
List of all file extensions supported by adaptor. |
default_ext |
str
|
The default file extension, e.g., 'json' (without '.'). |
formatted_ext_options |
String for Qt file dialog extension options. |
|
handles |
SleapObjectType
|
Returns the type of object that can be read/written. |
name |
str
|
Human-reading name of the file format |
Source code in sleap/io/format/adaptor.py
all_exts
property
¶
List of all file extensions supported by adaptor.
default_ext
property
¶
The default file extension, e.g., 'json' (without '.').
formatted_ext_options
property
¶
String for Qt file dialog extension options.
handles
property
¶
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.
name
property
¶
Human-reading name of the file format
can_read_file(file)
¶
can_write_filename(filename)
¶
does_match_ext(filename)
¶
Returns whether this adaptor can write format of this filename.