This attribute type can hold an arbitrary sized dictionary array.
Methods ¶
Static methods ¶
isValidName(str)
→ bool
Returns True
if the specified name is a valid attribute name, else returns
False
.
Instance Methods ¶
__getitem__(index)
→ pdg.Dictionary
Returns the attribute value at the specified index.
Note
This method returns a copy of the dictionary at the specifed index, and inline edits will not be applied to the underlying attribute. Instead of the following:
attrib[0]["key"] = "value" attrib[0]["integer"] = 1
Use:
dictionary = attrib[0] dictionary["key"] = "value" dictionary["integer"] = 1 attrib[0] = dictionary
__setitem__(index)
Sets the attribute value at the specified index
copyFrom(attribute)
Copies the dictionary data from attribute
into this attribute.
copyTo(owner, overwrite=True, deep_copy=False)
Copies this attribute onto the specified pdg.AttributeOwner.
If overwrite
is True
, the attribute will overwrite an existing attribute with the same name.
If deep_copy
is True
, a new copy of the attribute data will be made on the owner
. Otherwise, a shallow copy will be made if possible.
description(index=0, pretty_print=False)
Returns a string description of the Dictionary at the specified index.
If pretty_print
is True
, then the output string has padding and new lines added to make it more readable.
asFile(index=0, tag='', hash=0, own=False)
→ pdg.File
Casts the value at the specified index to a pdg.File object, with the specified tag, hash value and ownernship flag.
asNumber(index=0)
→ float
Casts the value at the specified index to a numeric value.
asString(index=0)
→ str
Casts the value at the specified index to a string value.
asValues()
→ str
Returns all of the values in the attribute as space separated string.
clear()
Clears all values in the array and sets the size to 0
hasFlag(flag)
→ bool
Returns true if the attribute has the specified pdg.attribFlag set.
hasFlags(bits)
→ bool
Returns true if the attribute has the specified pdg.attribFlag bits
set. The bits should be passed in as an integer, ORed from entries in the
attribFlags
enum.
hasAnyFlags(bits)
→ bool
Returns true if the attribute has any of specified pdg.attribFlag bits
set. The bits should be passed in as an integer, ORed from entries in the
attribFlags
enum.
importAttributes(pattern, work_item, index=0, overwrite=
pdg.attribOverwrite.Match)
Imports attributes matching the pdg.AttributePattern pattern
from the
specified work_item
as key/value pairs, and adds them to the dictionary at
index
. The overwrite
parameter determines whether or not existing keys
in the dictionary should be replaced or preserved.
mergeValue(dict, index=0)
Merges the specified pdg.Dictionary dict
into this dictionary attribute at the specified index
.
queryF(str)
→ float
Makes a floating point query using the attribute evaluator syntax by recursively indexing into any nested dictionaries or arrays.
queryS(str)
→ str
Makes a string value query using the attribute evaluator syntax by recursively indexing into any nested dictionaries or arrays.
reduce(merge_op, stride=1)
Reduces an array of dictionaries to a single value, using the specified pdg.attribMergeType and array stride length.
setFlag(flag, value=True)
→ bool
Sets or clears the specified pdg.attribFlag. Returns True
if the flag value was modified.
setFlags(flag, bits)
→ bool
Sets the attribute flags to the specified bits. Returns True
if the flag value was modified.
setValue(value, index=0)
Sets the value of the attribute at the specified index. This can also be
accessed with array brackets, e.g. attrib[2] = 5
.
setValues(array)
Sets the array contents of the attribute
truncate(length)
Truncates the array to the specified length.
value(index=0)
→ pdg.Dictionary
Returns the value of the attribute at the specified index. This can also be
accessed with array brackets, e.g. attrib[0]
.
flags
: int
Property
The flag bit vector, contains ORed bits from the pdg.attribFlag enum.
hasData
: bool
Property
Set to True
if the attribute has at least one array element.
isArray
: bool
Property
Set to True
for this type of attribute.
isNumeric
: bool
Property
Set to True
for this type of attribute.
isOwner
: bool
Property
Set to True
if this attribute was modified by the pdg.AttributeOwner that holds it, or False
if the attribute is an inherited shallow reference. Changing the value of this attribute will set this flag to True
.
name
: str
Property
The name of the attribute.
owner
: pdg.AttributeOwner
Property
The pdg.AttributeOwner that owns this attribute, i.e. a work item or graph instance.
size
: int
Property
The length of the array stored in the attribute. Can also be access as
len(attrib)
.
type
: pdg.attribType
Property
The type of the attribute, i.e. pdg.attribType.Dict
.
values
: list
of pdg.Dictionary
Property
The read-only array of values stored in the attribute.