# -*- coding: utf-8 -*-
"""
This module allows you to retrieve items shared trough the share sheet. A script can be ran from the share sheet.
"""

import PytoClasses

__PyContentViewController__ = PytoClasses.PyContentViewController
__PyExtensionContext__ = PytoClasses.PyExtensionContext

def extensionItems():
    """
    Returns the items shared trough the share sheet. Loaded with `NSExtensionContext`.
    """
    if (__PyContentViewController__.shared.extensionContext == None):
        print("warning: extensionItems: This API should only be used when the script is opened through the action extension.")
    return __PyExtensionContext__.items

def completeRequest():
    """
    Exits the extension if the script was loaded from the share sheet.
    """
    if (__PyContentViewController__.shared.extensionContext == None):
        print("warning: completeRequest: This API should only be used when the script is opened through the action extension.")
    __PyExtensionContext__.completeRequestReturningItems(None, completionHandler=None)
