I'm trying to load some examples with data load, I've followed all the instructions on the file and successfully generate my create function, but when I execute it, an error pops up:
Code: Select all
Welcome to the Protégé shell
>>> execfile("C:\EssentialAM\Python\generateLoadCommand.py")
Generate Load Command: given a class name, generates python function to load a class
generate(clsName)
help() - this message
>>> generate("Technology_Product")
------ SAVE BELOW THIS LINE ------
def getInstance(clsName, name):
if name is None:
return None
for curInstance in kb.getCls(clsName).getDirectInstances():
curInsName = curInstance.getOwnSlotValue(kb.getSlot('name'))
if ( curInsName == name ):
return curInstance
print "WARNING: unable to find class ", clsName, " with name: ", name
return None
def getInstances(clsName, listOfNames):
if listOfNames is None:
return []
return map(lambda(name): getInstance(clsName, name), listOfNames)
def createTechnology_Product(name , description , ImplementsTechnologyComponentsListOfInsName , MaintenanceCostFlt , TechnologyProductFunctionsOfferedListOfInsName , ExternalReferenceLinksListOfInsName , TechnologyProductArchitectureInsName , ProductLabelStr , TechnologyProductFamilyListOfInsName , ProductSupplierInsName ):
cls = kb.getCls("Technology_Product")
clsTagCode = 'TP::'
insName = "%s%s" % (clsTagCode, name)
ins = kb.getInstance(insName)
if ins is None:
print "Creating new instance: ", insName
ins = kb.createInstance(insName, cls)
else:
print "Updating existing instance: ", insName
ins.setOwnSlotValue(kb.getSlot("name"), name)
ins.setOwnSlotValue(kb.getSlot("description"), description)
ins.setOwnSlotValues(kb.getSlot("implements_technology_components"), getInstances("Technology_Provider_Role", ImplementsTechnologyComponentsListOfInsName))
ins.setOwnSlotValue(kb.getSlot("maintenance_cost"), MaintenanceCostFlt)
ins.setOwnSlotValues(kb.getSlot("technology_product_functions_offered"), getInstances("Technology_Function", TechnologyProductFunctionsOfferedListOfInsName))
ins.setOwnSlotValues(kb.getSlot("external_reference_links"), getInstances("External_Reference_Link", ExternalReferenceLinksListOfInsName))
ins.setOwnSlotValue(kb.getSlot("technology_product_architecture"), getInstance("Technology_Product_Architecture", TechnologyProductArchitectureInsName))
ins.setOwnSlotValue(kb.getSlot("product_label"), ProductLabelStr)
ins.setOwnSlotValues(kb.getSlot("technology_product_family"), getInstances("Product_Family", TechnologyProductFamilyListOfInsName))
ins.setOwnSlotValue(kb.getSlot("supplier_technology_product"), getInstance("Supplier", ProductSupplierInsName))
return ins
>>> execfile("C:\EssentialAM\Python\createTechnology_Product.py")
>>> createTechnology_Product("Visual Studio 2003","Application code development technology",["Software Development Language"],0.0,None,None,None,None,None,["Microsoft"])
Creating new instance: TP::Visual Studio 2003
Traceback (innermost last):
File "<string>", line 1, in ?
File "C:\EssentialAM\Python\createTechnology_Product.py", line 36, in createTechnology_Product
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in getInstances
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in <lambda>
ValueError: unpack sequence too long
exception from Jython: Traceback (innermost last):
File "<string>", line 1, in ?
File "C:\EssentialAM\Python\createTechnology_Product.py", line 36, in createTechnology_Product
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in getInstances
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in <lambda>
ValueError: unpack sequence too long
: Traceback (innermost last):
File "<string>", line 1, in ?
File "C:\EssentialAM\Python\createTechnology_Product.py", line 36, in createTechnology_Product
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in getInstances
File "C:\EssentialAM\Python\createTechnology_Product.py", line 19, in <lambda>
ValueError: unpack sequence too long
>>>
Thanks!
Ana