Module IDProp
[hide private]
[frames] | no frames]

Source Code for Module IDProp

1 -class IDGroup:
2 """ 3 The IDGroup Type 4 ================ 5 This type supports both iteration and the [] 6 operator to get child ID properties. 7 8 You can also add new properties using the [] operator. 9 For example:: 10 11 group['a float!'] = 0.0 12 group['an int!'] = 0 13 group['a string!'] = "hi!" 14 group['an array!'] = [0, 0, 1.0, 0] 15 16 group['a subgroup!] = {"float": 0.0, "an int": 1.0, "an array": [1, 2], 17 "another subgroup": {"a": 0.0, "str": "bleh"}} 18 19 Note that for arrays, the array type defaults to int unless a float is found 20 while scanning the template list; if any floats are found, then the whole 21 array is float. Note that double-precision floating point numbers are used for 22 python-created float ID properties and arrays (though the internal C api does 23 support single-precision floats, and the python code will read them). 24 25 You can also delete properties with the del operator. For example: 26 27 del group['property'] 28 29 To get the type of a property, use the type() operator, for example:: 30 31 if type(group['bleh']) == str: pass 32 33 To tell if the property is a group or array type, import the Blender.Types module and test 34 against IDGroupType and IDArrayType, like so:: 35 36 from Blender.Types import IDGroupType, IDArrayType. 37 38 if type(group['bleghr']) == IDGroupType: 39 (do something) 40 41 @ivar name: The name of the property 42 @type name: string 43 """ 44
45 - def pop(item):
46 """ 47 Pop an item from the group property. 48 @type item: string 49 @param item: The item name. 50 @rtype: can be dict, list, int, float or string. 51 @return: The removed property. 52 """
53
54 - def update(updatedict):
55 """ 56 Updates items in the dict, similar to normal python 57 dictionary method .update(). 58 @type updatedict: dict 59 @param updatedict: A dict of simple types to derive updated/new IDProperties from. 60 @rtype: None 61 @return: None 62 """
63
64 - def keys():
65 """ 66 Returns a list of the keys in this property group. 67 @rtype: list of strings. 68 @return: a list of the keys in this property group. 69 """
70
71 - def values():
72 """ 73 Returns a list of the values in this property group. 74 75 Note that unless a value is itself a property group or an array, you 76 cannot change it by changing the values in this list, you must change them 77 in the parent property group. 78 79 For example, 80 81 group['some_property'] = new_value 82 83 . . .is correct, while, 84 85 values = group.values() 86 values[0] = new_value 87 88 . . .is wrong. 89 90 @rtype: list of strings. 91 @return: a list of the values in this property group. 92 """
93
94 - def iteritems():
95 """ 96 Implements the python dictionary iteritmes method. 97 98 For example:: 99 100 for k, v in group.iteritems(): 101 print "Property name: " + k 102 print "Property value: " + str(v) 103 104 @rtype: an iterator that spits out items of the form [key, value] 105 @return: an iterator. 106 """
107
109 """ 110 Converts the entire property group to a purely python form. 111 112 @rtype: dict 113 @return: A python dictionary representing the property group 114 """
115
116 -class IDArray:
117 """ 118 The IDArray Type 119 ================ 120 121 @ivar type: returns the type of the array, can be either IDP_Int or IDP_Float 122 """ 123
124 - def __getitem__(index):
125 pass
126
127 - def __setitem__(index, value):
128 pass
129
130 - def __len__():
131 pass
132