Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return str(self.name)
LIBMTP_Album._fields_ = [
("album_id", ctypes.c_uint32),
("parent_id", ctypes.c_uint32),
("storage_id", ctypes.c_uint32),
("name", ctypes.c_char_p),
("artist", ctypes.c_char_p),
("composer", ctypes.c_char_p),
("genre", ctypes.c_char_p),
("tracks", ctypes.POINTER(ctypes.c_uint32)),
("no_tracks", ctypes.c_uint32),
("next", ctypes.POINTER(LIBMTP_Album)),
]
class MTPAlbum(BaseModel):
"""
MTPAlbum
An object representing a single album.
"""
def _get_album_id(self):
"""
A unique identifier for the album - typically, you don't manipulate
this value manually.
"""
return int(self.base_structure.album_id)
def _set_album_id(self, value):
self.base_structure.album_id = ctypes.c_uint32(int(value))
("duration", ctypes.c_uint32),
("samplerate", ctypes.c_uint32),
("nochannels", ctypes.c_uint16),
("wavecodec", ctypes.c_uint32),
("bitrate", ctypes.c_uint32),
("bitratetype", ctypes.c_uint16),
("rating", ctypes.c_uint16),
("usecount", ctypes.c_uint32),
("filesize", ctypes.c_uint64),
("filetype", ctypes.c_int),
("next", ctypes.POINTER(LIBMTP_Track)),
]
LIBMTP_Track_p = ctypes.POINTER(LIBMTP_Track)
class MTPTrack(BaseModel):
"""
MTPTrack
An object representing a music track
"""
@property
def item_id(self):
"""
The track's unique identifier
@return: Track ID
@rtype: int
"""
return int(self.base_structure.item_id)
def _get_parent_id(self):
"""
def __repr__(self):
return "%s (%s)" % (self.name, self.playlist_id)
LIBMTP_Playlist._fields_ = [
("playlist_id", ctypes.c_uint32),
("parent_id", ctypes.c_uint32),
("storage_id", ctypes.c_uint32),
("name", ctypes.c_char_p),
("tracks", ctypes.POINTER(ctypes.c_uint32)),
("no_tracks", ctypes.c_uint32),
("next", ctypes.POINTER(LIBMTP_Playlist)),
]
LIBMTP_Playlist_p = ctypes.POINTER(LIBMTP_Playlist)
class MTPPlaylist(BaseModel):
"""
MTPPlaylist
An object representing a playlist on a MTP device.
"""
@property
def playlist_id(self):
"""
The unique playlist identifier
@rtype: int
@return: Playlist ID
"""
return int(self.base_structure.playlist_id)
def _get_parent_id(self):
"""
Contains the ctypes structure for LIBMTP_error_struct
"""
def __repr__(self):
return int(self.errornumber)
LIBMTP_Error._fields_ = [
("errornumber", ctypes.c_int),
("error_text", ctypes.c_char_p),
("next", ctypes.POINTER(LIBMTP_Error)),
]
LIBMTP_Error_p = ctypes.POINTER(LIBMTP_Error)
class MTPError(BaseModel):
"""
MTPError
An object representing an single MTP error.
"""
@property
def errornumber(self):
"""
Returns the error number
@return: LibMTP error number
@rtype: int
"""
return int(self.base_structure.errornumber)
@property
BaseModel
Provides a basic model for Pythonic PyMTP data structures
"""
def __init__(self, base_structure):
"""
Initializes a BaseModel for the supplied base_structure.
@param base_structure: The underlying CTypes structure to "wrap".
@type base_structure: any ctypes.structure object
@return: Nothing
"""
self.base_structure = base_structure
class IterableModel(BaseModel):
"""
IterableModel
Provides a basic iterable model for CTypes data types that specify
a "next" parameter (as a pointer).
You still have to define __getitem__, etc, but you can use _get_item
to retrieve the object!
"""
def _get_item(self, level):
"""
Returns the "level"th object in the list. If the level exceeds
the number of objects in the list, it'll raise IndexError.
@type level: int
("default_playlist_folder", ctypes.c_uint32),
("default_picture_folder", ctypes.c_uint32),
("default_video_folder", ctypes.c_uint32),
("default_organizer_folder", ctypes.c_uint32),
("default_zencast_folder", ctypes.c_uint32),
("default_album_folder", ctypes.c_uint32),
("default_text_folder", ctypes.c_uint32),
("cd", ctypes.c_void_p),
("extensions", ctypes.c_void_p),
("cached", ctypes.c_int),
("next", ctypes.POINTER(LIBMTP_MTPDevice)),
]
LIBMTP_MTPDevice_p = ctypes.POINTER(LIBMTP_MTPDevice)
class MTPDevice(BaseModel):
"""
MTPDevice
An object containing information about an MTP device
"""
@property
def storage(self):
"""
The storage objects for the device
@return: The device storages
@rtype: L{MTPDeviceStorages}
"""
return MTPDeviceStorages(self.base_structure.storage)
@property
Contains the CTypes structure for LIBMTP_device_entry_struct
"""
def __repr__(self):
return "%s %s" % (self.vendor_id, self.product_id)
LIBMTP_DeviceEntry._fields_ = [
("vendor", ctypes.c_char_p),
("vendor_id", ctypes.c_uint16),
("product", ctypes.c_char_p),
("product_id", ctypes.c_uint16),
("device_flags", ctypes.c_uint32),
]
class MTPDeviceEntry(BaseModel):
"""
MTPDeviceEntry
An object representing a MTP device entry.
"""
@property
def vendor(self):
"""
The vendor information for the device
@rtype: str
@return: string containing the vendor of the device
"""
return str(self.base_structure.vendor)
@property
LIBMTP_DeviceStorage._fields_ = [
("storage_id", ctypes.c_uint32),
("storage_type", ctypes.c_uint16),
("filesystem_type", ctypes.c_uint16),
("access_capability", ctypes.c_uint16),
("max_capacity", ctypes.c_uint64),
("free_space", ctypes.c_uint64),
("free_space_in_objects", ctypes.c_uint64),
("storage_description", ctypes.c_char_p),
("volume_id", ctypes.c_char_p),
("next", ctypes.POINTER(LIBMTP_DeviceStorage)),
("prev", ctypes.POINTER(LIBMTP_DeviceStorage)),
]
class MTPDeviceStorage(BaseModel):
"""
MTPDeviceStorage
An object representing a MTP Device storage.
"""
@property
def storage_id(self):
"""
The storage unique identifier
"""
return int(self.base_structure.storage_id)
@property
def storage_type(self):
"""
The storage type of the storage as an integer.
return "%s (%s)" % (self.filename, self.item_id)
LIBMTP_File._fields_ = [
("item_id", ctypes.c_uint32),
("parent_id", ctypes.c_uint32),
("storage_id", ctypes.c_uint32),
("filename", ctypes.c_char_p),
("filesize", ctypes.c_uint64),
("modificationdate", ctypes.c_int),
("filetype", ctypes.c_int),
("next", ctypes.POINTER(LIBMTP_File)),
]
LIBMTP_File_p = ctypes.POINTER(LIBMTP_File)
class MTPFile(BaseModel):
"""
MTPFile
A class representing a file on an MTP device.
"""
@property
def item_id(self):
"""
The unique identifier for the file
@return: File identifier
@rtype: int
"""
return int(self.base_structure.item_id)
def _get_parent_id(self):
"""
LIBMTP_RawDevice
The ctypes tructure for LIBMTP_raw_device_struct
"""
def __repr__(self):
return self.devnum
LIBMTP_RawDevice._fields_ = [
("device_entry", LIBMTP_DeviceEntry),
("bus_location", ctypes.c_uint32),
("devnum", ctypes.c_uint8),
]
LIBMTP_RawDevice_p = ctypes.POINTER(LIBMTP_RawDevice)
class MTPRawDevice(BaseModel):
"""
MTPRawDevice
An object representing a raw MTP device entry
"""
@property
def device_id(self):
"""
A somewhat unique identifier for the device based on the bus
location, device number, vendor_id and product_id.
B{Don't trust this to be consistent between instances!}
@rtype: str
@return: Identifier
"""
return "%s%s-%s%s" % (self.bus_location, self.devnum,
self.device_entry.vendor_id, self.device_entry.product_id)