ItemProvider¶
- class pasteboard.ItemProvider(foundation_item_provider: NSItemProvider)¶
A bridge to Foundation’s
NSItemProviderclass. AnItemProviderobject can load data as one or more type of data. Instances of this class are returned byitem_provider()andshortcuts_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 fromdata()oropen()
- 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 byget_type_identifiers()as the type identifier. You must use this function with thewithkeyword:with item_provider.open() as f: f.read()