ItemProvider

class pasteboard.ItemProvider(foundation_item_provider: NSItemProvider)

A bridge to Foundation’s NSItemProvider class. An ItemProvider object can load data as one or more type of data. Instances of this class are returned by item_provider() and shortcuts_attachments().

data(type_identifier: str) → bytes

Returns the data for the given type identifier as bytes.

Parameters:

type_identifier – An UTI. Can be returned from get_type_identifiers().

get_file_path() → str

Returns the file path if the item is a file. If it returns None, you can load its content from data() or open()

get_suggested_name() → str

Returns the name of the file from which the receiver was created or None.

get_type_identifiers() → list[str]

Returns a list of type identifiers (UTI) that can be loaded.

open()

Opens the receiver as a file in 'rb' mode with the first item item returned by get_type_identifiers() as the type identifier. You must use this function with the with keyword:

with item_provider.open() as f:
    f.read()