Esempio n. 1
0
def add_reascript(path, section_id=0, commit=True):
    """
    Add a ReaScript and return the new action ID.

    Parameters
    ----------
    path : str
        Path to script.
    section_id : int, optional (default=0, corresponds to main section).
        Action section ID to which the script must be added.
    commit : bool, optional
        Whether to commit change. Use it when adding a single script.
        You can optimize bulk adding `n` scripts by setting
        `commit=False` for the first `n-1` calls and `commit=True` for
        the last call.

    Returns
    -------
    action_id : int
        New ReaScript action ID.
    """
    if not os.path.isfile(path):
        raise FileNotFoundError(path)
    path = os.path.abspath(path)
    action_id = RPR.AddRemoveReaScript(True, section_id, path, commit)
    if action_id == 0:
        message = "Script at {} wasn't successfully added.".format(path)
        raise ValueError(message)
    return action_id
Esempio n. 2
0
def remove_reascript(path, section_id=0, commit=True):
    """
    Remove a ReaScript.

    Parameters
    ----------
    path : str
        Path to script.
    section_id : int, optional (default=0, corresponds to main section).
        Action section ID to which the script must be added.
    commit : bool, optional
        Whether to commit change. Use it when removing a single script.
        You can optimize bulk removing `n` scripts by setting
        `commit=False` for the first `n-1` calls and `commit=True` for
        the last call.
    """
    path = os.path.abspath(path)
    success = RPR.AddRemoveReaScript(False, section_id, path, commit)
    if not success:
        message = "Script at {} wasn't successfully added.".format(path)
        raise ValueError(message)