Debian Codegraph @

stubs/calibre_extensions/libmtp.pyi

raw
1 from collections.abc import Callable
2
3 class MTPError(Exception):
4 pass
5
6 class Device:
7 def __init__(
8 self,
9 busnum: int,
10 devnum: int,
11 vendor_id: int,
12 product_id: int,
13 vendor: str,
14 product: str,
15 usb_serialnum: str | None,
16 ) -> None:
17 "Device"
18 pass
19
20 def update_storage_info(self) -> None:
21 "update_storage_info() -> Reread the storage info from the device (total, space, free space, storage locations, etc.)"
22 pass
23
24 def get_filesystem(
25 self, storage_id: int, callback: Callable[[dict[str, int | str | bool], int], object]
26 ) -> tuple[list[dict[str, int | str | bool]], list[tuple[int, str]]]:
27 """get_filesystem(storage_id, callback) -> Get the list of files and folders on
28 the device in storage_id. Returns files, errors. callback must be a callable that
29 is called as with (entry, level). It is called with every found object. If callback
30 returns False and the object is a folder, it is not recursed into.
31 """
32 pass
33
34 def get_file(self, fileid: int, stream: object, callback: Callable[[int, int], object] | None = None) -> tuple[bool, list[tuple[int, str]]]:
35 """get_file(fileid, stream, callback=None) -> Get the file specified by fileid from
36 the device. stream must be a file-like object. The file will be written to it.
37 callback works the same as in get_filelist(). Returns ok, errs, where errs is a
38 list of errors (if any).
39 """
40 pass
41
42 def get_file_by_name(
43 self,
44 storage_id: int,
45 parent_id: int,
46 names: tuple[str, ...],
47 stream: object,
48 callback: Callable[[int, int], object] | None = None,
49 ) -> tuple[bool, list[tuple[int, str]]] | None:
50 """get_file_by_name(storage_id, parent_id, names, stream, callback=None) -> Get
51 the file specified by names (a tuple of name components) relative to parent_id
52 from the device. stream must be a file-like object. The file will be written to it.
53 callback works the same as in get_filelist(). Returns None or (ok, errs), where
54 errs is a list of errors (if any).
55 """
56 pass
57
58 def list_folder_by_name(self, storage_id: int, parent_id: int, names: tuple[str, ...]) -> list[dict[str, int | str | bool]] | None:
59 """list_folder_by_name(storage_id, parent_id, names) -> List the folder specified
60 by names (a tuple of name components) relative to parent_id from the device.
61 Return None or a list of entries.
62 """
63 pass
64
65 def get_metadata_by_name(
66 self, storage_id: int, parent_id: int, names: tuple[str, ...]
67 ) -> tuple[dict[str, int | str | bool] | None, list[tuple[int, str]]] | None:
68 """get_metadata_by_name(storage_id, parent_id, names) -> Return metadata for
69 specified name (a tuple of name components) relative to parent from the device.
70 Return (metadata, errs).
71 """
72 pass
73
74 def put_file(
75 self,
76 storage_id: int,
77 parent_id: int,
78 filename: str,
79 stream: object,
80 size: int,
81 callback: Callable[[int, int], object] | None = None,
82 ) -> tuple[dict[str, int | str | bool] | None, list[tuple[int, str]]]:
83 """put_file(storage_id, parent_id, filename, stream, size, callback=None) -> Put a
84 file on the device. The file is read from stream. It is put inside the folder
85 identified by parent_id on the storage identified by storage_id. Use parent_id=0
86 to put it in the root. stream must be a file-like object. size is the size in bytes
87 of the data in stream. callback works the same as in get_filelist(). Returns
88 fileinfo, errs, where errs is a list of errors (if any), and fileinfo is a file
89 information dictionary, as returned by get_filelist(). fileinfo will be None if
90 case or errors.
91 """
92 pass
93
94 def create_folder(self, storage_id: int, parent_id: int, name: str) -> tuple[dict[str, int | str | bool] | None, list[tuple[int, str]]]:
95 """create_folder(storage_id, parent_id, name) -> Create a folder named name under
96 parent parent_id (use 0 for root) in the storage identified by storage_id. Returns
97 folderinfo, errors, where folderinfo is the same dict as returned by
98 get_folderlist(), it will be None if there are errors.
99 """
100 pass
101
102 def delete_object(self, id: int) -> tuple[bool, list[tuple[int, str]]]:
103 "delete_object(id) -> Delete the object identified by id from the device. Can be used to delete files, folders, etc. Returns ok, errs."
104 pass
105
106 @property
107 def friendly_name(self) -> str | None:
108 "The friendly name of this device, can be None."
109 pass
110
111 @property
112 def manufacturer_name(self) -> str | None:
113 "The manufacturer name of this device, can be None."
114 pass
115
116 @property
117 def model_name(self) -> str | None:
118 "The model name of this device, can be None."
119 pass
120
121 @property
122 def serial_number(self) -> str | None:
123 "The serial number of this device, can be None."
124 pass
125
126 @property
127 def device_version(self) -> str | None:
128 "The device version of this device, can be None."
129 pass
130
131 @property
132 def ids(self) -> tuple[int, int, int, int, str | None]:
133 "The ids of the device (busnum, devnum, vendor_id, product_id, usb_serialnum)"
134 pass
135
136 @property
137 def storage_info(self) -> list[dict[str, int | str | bool]]:
138 """Information about the storage locations on the device. Returns a list of
139 dictionaries where each dictionary corresponds to the LIBMTP_devicestorage_struct.
140 """
141 pass
142
143 LIBMTP_VERSION_STRING: str
144 LIBMTP_DEBUG_NONE: int
145 LIBMTP_DEBUG_PTP: int
146 LIBMTP_DEBUG_PLST: int
147 LIBMTP_DEBUG_USB: int
148 LIBMTP_DEBUG_DATA: int
149 LIBMTP_DEBUG_ALL: int
150 LIBMTP_FILES_AND_FOLDERS_ROOT: int
151
152 def set_debug_level(level: int) -> None:
153 "set_debug_level(level)\n\nSet the debug level bit mask, see LIBMTP_DEBUG_* constants."
154 pass
155
156 def is_mtp_device(busnum: int, devnum: int) -> bool:
157 """is_mtp_device(busnum, devnum)
158
159 A probe is done and True returned if the probe succeeds. Note that probing can cause
160 some devices to malfunction, and it is not very reliable, which is why we prefer to
161 use the device database.
162 """
163 pass
164
165 def known_devices() -> list[tuple[int, int]]:
166 "known_devices() -> Return the list of known (vendor_id, product_id) combinations."
167 pass