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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
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)
¶
Returns whether this adaptor can read this file.
Source code in sleap/io/format/adaptor.py
53 54 55 | |
can_write_filename(filename)
¶
Returns whether this adaptor can write format of this filename.
Source code in sleap/io/format/adaptor.py
57 58 59 | |
does_match_ext(filename)
¶
Returns whether this adaptor can write format of this filename.
Source code in sleap/io/format/adaptor.py
79 80 81 82 83 84 85 | |
does_read()
¶
Returns whether this adaptor supports reading.
Source code in sleap/io/format/adaptor.py
61 62 63 | |
does_write()
¶
Returns whether this adaptor supports writing.
Source code in sleap/io/format/adaptor.py
65 66 67 | |
read(file)
¶
Reads the file and returns the appropriate deserialized object.
Source code in sleap/io/format/adaptor.py
69 70 71 | |
write(filename, source_object)
¶
Writes the object to a file.
Source code in sleap/io/format/adaptor.py
73 74 75 | |
SleapObjectType
¶
Bases: Enum
Types of files that an adaptor could read/write.
Source code in sleap/io/format/adaptor.py
11 12 13 14 15 | |