Setting properties
Nodes, flows, models, and outputs all have properties that can be accessed and, in most cases, set. Properties are typically used to modify the behavior or appearance of the object. The methods that are available for accessing and setting object properties are summarized in the following table.
Method | Return type | Description |
---|---|---|
p.getPropertyValue(propertyName) |
Object | Returns the value of the named property or None if
no such property exists. |
p.setPropertyValue(propertyName, value) |
Not applicable | Sets the value of the named property. |
p.setPropertyValues(properties) |
Not applicable | Sets the values of the named properties. Each entry in the properties map consists of a key that represents the property name and the value that should be assigned to that property. |
p.getKeyedPropertyValue( propertyName, keyName) |
Object | Returns the value of the named property and
associated key or None if no such property or key
exists. |
p.setKeyedPropertyValue( propertyName, keyName,
value) |
Not applicable | Sets the value of the named property and key. |
For example, the following script sets the value of a Derive node for a flow:
stream = modeler.script.stream()
node = stream.findByType("derive", None)
node.setPropertyValue("name_extension", "new_derive")
Alternatively, you might want to filter a field from a Filter node. In this case, the value is also keyed on the field name. For example:
stream = modeler.script.stream()
# Locate the filter node ...
node = stream.findByType("filter", None)
# ... and filter out the "Na" field
node.setKeyedPropertyValue("include", "Na", False)