Inheritance |
|
This object represents the data for a work item that cooks a Python script, for example work items created using the Python Script TOP node. It is a specialization of the basic pdg.WorkItemData class, and cinludes a serializad Python script in addition to regular work item attributes. Work items that use script data can be cooked using the Python Script Service, or the $HHP/pdgjob/pythonscript.py
work item job script.
You can construct work items that store script data from Python. For example, adding following code in the Python Processor node’s onGenerate callback constructs a work item that runs Python code out of process:
new_item = item_holder.addWorkItem(typeName="scriptdata") new_item.data.setScript("print('running custom script')") new_item.setCommand("hython $HHP/pdgjob/pythonscript.py")
Methods ¶
setScript(script)
Sets the Python script stored on the data object.
script
: str
Property
Returns the script string currently associated with the data object.
Methods from pdg.TypeInstance ¶
type
: pdg.BaseType
Property
The pdg.BaseType object used to construct this instance
typeName
: str
Property
The type name of the type
object.
Methods from pdg.WorkItemData ¶
clearFloatData()
Clears all float attributes on the work item.
clearIntData()
Clears all integer attributes on the work item.
clearStringData()
Clears all string attributes on the work item
data(name, index)
→ int
, float
or str
Returns a float, int or string attribute values for the specified name and index.
dataArray(name)
→ list
of int
, float
, or str
Returns a list of float, int or string attribute values for the specified name.
deserializeString(string)
→ bool
Deserializes the work item data in string
, and returns True
on success.
floatData(name, index)
→ float
Looks up a floating point attribute value with the specified name and index.
floatDataArray(name)
→ list
of float
Looks up a floating point attribute array with the specified name.
intData(name, index)
→ int
Looks up an integer attribute value with the specified name and index.
intDataArray(name)
→ list
of int
Looks up an integer attribute array with the specified name.
removeData(name, index=0)
→ bool
Removes an attribute with the specified name. If index
is greater than 0,
only attribute values beyond the index are removed - the attribute array is
truncated. Returns True
on success.
setFloat(name, value, index)
→ bool
Sets a floating point attribute value with the specified name and index.
setFloatArray(name, floats)
→ bool
Sets a floating point attribute array with the specified name.
setInt(name, value, index)
→ bool
Sets an integer attribute value with the specified name and index.
setIntArray(name, value)
→ bool
Sets an integer attribute array with the specified name.
setString(name, value, index)
→ bool
Sets a string attribute value with the specified name and index.
setStringArray(name, value)
→ bool
Sets a string attribute array with the specified name.
stringData(name, index)
→ str
Looks up a string attribute value with the specified name and index.
stringDataArray(name)
→ list
of str
Looks up a string attribute array with the specified name.
allDataMap
: dict
of list
of int
, float
, and str
Property
All the data on the work item, as a dict from name to arrays of string, float and int values.
floatDataMap
: dict
of list
of float
Property
The floating point attributes on the work item, as a map to lists of float values.
intDataMap
: dict
of list
of int
Property
The integer attributes on the work item, as a map to lists of int values.
stringDataMap
: dict
of list
of str
Property
The string attributes on the work item, as a map to lists of string values.
workItem
: pdg.WorkItem
Property
The work item that owns this data object.