| 1 |
from collections.abc import Callable |
| 2 |
from typing import Any |
| 3 |
|
| 4 |
class WPDError(Exception): |
| 5 |
pass |
| 6 |
|
| 7 |
class NoWPD(Exception): |
| 8 |
pass |
| 9 |
|
| 10 |
class WPDFileBusy(Exception): |
| 11 |
pass |
| 12 |
|
| 13 |
class Device: |
| 14 |
data: dict[str, Any] |
| 15 |
|
| 16 |
def __init__(self, pnp_id: str) -> None: |
| 17 |
"Device" |
| 18 |
pass |
| 19 |
|
| 20 |
def update_data(self) -> None: |
| 21 |
"update_data() -> Reread the basic device data from the device (total, space, free space, storage locations, etc.)" |
| 22 |
pass |
| 23 |
|
| 24 |
def get_filesystem(self, storage_id: str, callback: Callable[[dict[str, Any], int], bool]) -> dict[str, dict[str, Any]]: |
| 25 |
"""get_filesystem(storage_id, callback) -> Get all files/folders on the storage |
| 26 |
identified by storage_id. Tries to use bulk operations when possible. callback |
| 27 |
must be a callable that is called as (object, level). It is called with every |
| 28 |
found object. If the callback returns False and the object is a folder, it is not |
| 29 |
recursed into. |
| 30 |
""" |
| 31 |
pass |
| 32 |
|
| 33 |
def list_folder_by_name(self, parent_id: str, names: tuple[str, ...]) -> dict[str, dict[str, Any]] | None: |
| 34 |
"""list_folder_by_name(parent_id, names) -> List the folder specified by names |
| 35 |
(a tuple of name components) relative to parent_id from the device. Return None |
| 36 |
or a list of entries. |
| 37 |
""" |
| 38 |
pass |
| 39 |
|
| 40 |
def get_metadata_by_name(self, parent_id: str, names: tuple[str, ...]) -> dict[str, Any] | None: |
| 41 |
"""get_metadata_by_name(parent_id, names) -> get metadata for the file or folder |
| 42 |
specified by names (a tuple of name components) relative to parent_id from the |
| 43 |
device. Return None or metadata. |
| 44 |
""" |
| 45 |
pass |
| 46 |
|
| 47 |
def get_file(self, object_id: str, stream: Any, callback: Callable[[int, int], None] | None = None) -> None: |
| 48 |
"""get_file(object_id, stream, callback=None) -> Get the file identified by |
| 49 |
object_id from the device. The file is written to the stream object, which must be |
| 50 |
a file like object. If callback is not None, it must be a callable that accepts |
| 51 |
two arguments: (bytes_read, total_size). It will be called after each chunk is |
| 52 |
read from the device. Note that it can be called multiple times with the same |
| 53 |
values. |
| 54 |
""" |
| 55 |
pass |
| 56 |
|
| 57 |
def get_file_by_name(self, parent_id: str, names: tuple[str, ...], stream: Any, callback: Callable[[int, int], None] | None = None) -> None: |
| 58 |
"""get_file_by_name(storage_id, parent_id, names, stream, callback=None) -> Get |
| 59 |
the file specified by names (a tuple of name components) relative to parent_id |
| 60 |
from the device. stream must be a file-like object. The file will be written to |
| 61 |
it. callback works the same as in get_filelist(). |
| 62 |
""" |
| 63 |
pass |
| 64 |
|
| 65 |
def create_folder(self, parent_id: str, name: str) -> dict[str, Any]: |
| 66 |
"create_folder(parent_id, name) -> Create a folder. Returns the folder metadata." |
| 67 |
pass |
| 68 |
|
| 69 |
def delete_object(self, object_id: str) -> None: |
| 70 |
"delete_object(object_id) -> Delete the object identified by object_id. Note that trying to delete a non-empty folder will raise an error." |
| 71 |
pass |
| 72 |
|
| 73 |
def put_file( |
| 74 |
self, |
| 75 |
parent_id: str, |
| 76 |
name: str, |
| 77 |
stream: Any, |
| 78 |
size_in_bytes: int, |
| 79 |
callback: Callable[[int, int], None] | None = None, |
| 80 |
) -> dict[str, Any]: |
| 81 |
"""put_file(parent_id, name, stream, size_in_bytes, callback=None) -> Copy a file |
| 82 |
from the stream object, creating a new file on the device with parent identified |
| 83 |
by parent_id. Returns the file metadata of the newly created file. callback should |
| 84 |
be a callable that accepts two argument: (bytes_written, total_size). It will be |
| 85 |
called after each chunk is written to the device. Note that it can be called |
| 86 |
multiple times with the same arguments. |
| 87 |
""" |
| 88 |
pass |
| 89 |
|
| 90 |
def init(name: str, major_version: int, minor_version: int, revision: int) -> None: |
| 91 |
"""init(name, major_version, minor_version, revision) |
| 92 |
|
| 93 |
Initializes this module. Call this method *only* in the thread in which you intend |
| 94 |
to use this module. Also remember to call uninit before the thread exits. |
| 95 |
""" |
| 96 |
pass |
| 97 |
|
| 98 |
def uninit() -> None: |
| 99 |
"""uninit() |
| 100 |
|
| 101 |
Uninitialize this module. Must be called in the same thread as init(). Do not use |
| 102 |
any function/objects from this module after uninit has been called. |
| 103 |
""" |
| 104 |
pass |
| 105 |
|
| 106 |
def enumerate_devices() -> tuple[str, ...]: |
| 107 |
"""enumerate_devices() |
| 108 |
|
| 109 |
Get the list of device PnP ids for all connected devices recognized by the WPD |
| 110 |
service. Do not call too often as it is resource intensive. |
| 111 |
""" |
| 112 |
pass |
| 113 |
|
| 114 |
def device_info(pnp_id: str) -> dict[str, Any]: |
| 115 |
"device_info(pnp_id)\n\n Return basic device information for the device identified by pnp_id (which you get from enumerate_devices)." |
| 116 |
pass |