Module IDProp

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. 22 23 You can also delete properties with the del operator. For example: 24 25 del group['property'] 26 27 To get the type of a property, use the type() operator, for example:: 28 29 if type(group['bleh']) == str: pass 30 31 To tell if the property is a group or array type, import the Blender.Types module and test 32 against IDGroupType and IDArrayType, like so:: 33 34 from Blender.Types import IDGroupType, IDArrayType. 35 36 if type(group['bleghr']) == IDGroupType: 37 (do something) 38 39 @ivar name: The name of the property 40 @type name: string 41 """ 42
43 - def pop(item):
44 """ 45 Pop an item from the group property. 46 @type item: string 47 @param item: The item name. 48 @rtype: can be dict, list, int, float or string. 49 @return: The removed property. 50 """
51
52 - def update(updatedict):
53 """ 54 Updates items in the dict, similar to normal python 55 dictionary method .update(). 56 @type updatedict: dict 57 @param updatedict: A dict of simple types to derive updated/new IDProperties from. 58 @rtype: None 59 @return: None 60 """
61
62 - def keys():
63 """ 64 Returns a list of the keys in this property group. 65 @rtype: list of strings. 66 @return: a list of the keys in this property group. 67 """
68
69 - def values():
70 """ 71 Returns a list of the values in this property group. 72 73 Note that unless a value is itself a property group or an array, you 74 cannot change it by changing the values in this list, you must change them 75 in the parent property group. 76 77 For example, 78 79 group['some_property'] = new_value 80 81 . . .is correct, while, 82 83 values = group.values() 84 values[0] = new_value 85 86 . . .is wrong. 87 88 @rtype: list of strings. 89 @return: a list of the values in this property group. 90 """
91
92 - def iteritems():
93 """ 94 Implements the python dictionary iteritmes method. 95 96 For example:: 97 98 for k, v in group.iteritems(): 99 print "Property name: " + k 100 print "Property value: " + str(v) 101 102 @rtype: an iterator that spits out items of the form [key, value] 103 @return: an iterator. 104 """
105
107 """ 108 Converts the entire property group to a purely python form. 109 110 @rtype: dict 111 @return: A python dictionary representing the property group 112 """
113
114 -class IDArray:
115 """ 116 The IDArray Type 117 ================ 118 119 @ivar type: returns the type of the array, can be either IDP_Int or IDP_Float 120 """ 121
122 - def __getitem__(index):
123 pass
124
125 - def __setitem__(index, value):
126 pass
127
128 - def __len__():
129 pass
130