如何使用IronPython脚本在Spotfire库中创建文件夹

时间:2016-03-10 10:15:08

标签: ironpython spotfire

我想在Spotfire Library中创建一个文件夹,并使用IronPython脚本保存分析文件。但是我不确定如何在Library Manager的create folder函数中传递LibraryItem。

1 个答案:

答案 0 :(得分:0)

您需要使用LibraryManager.TryGetItem方法选择父文件夹,然后将该文件夹和新文件夹名称传递给LibraryManager.CreateFolder方法。

这对我有用: -

# Import namespaces
from Spotfire.Dxp.Framework.Library import *

libraryManager = Document.GetService(LibraryManager)
parentFolder = '/path/parentFolder/'
newSubFolder = 'newSub'

parentFolderExists, folder = libraryManager.TryGetItem(parentFolder, LibraryItemType.Folder)
if parentFolderExists:
    subfolderExists, subfolder = libraryManager.TryGetItem(customer + newSubFolder + '/', LibraryItemType.Folder)
    if not subfolderExists:
        print customer
        libraryManager.CreateFolder(folder, newSubFolder, LibraryItemMetadataSettings())