topologicpy 0.4.8__py3-none-any.whl → 0.4.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- topologicpy/Aperture.py +46 -0
- topologicpy/Cell.py +1780 -0
- topologicpy/CellComplex.py +791 -0
- topologicpy/Cluster.py +591 -0
- topologicpy/Color.py +157 -0
- topologicpy/Context.py +56 -0
- topologicpy/DGL.py +2661 -0
- topologicpy/Dictionary.py +470 -0
- topologicpy/Edge.py +855 -0
- topologicpy/EnergyModel.py +1052 -0
- topologicpy/Face.py +1810 -0
- topologicpy/Graph.py +3526 -0
- topologicpy/Graph_Export.py +858 -0
- topologicpy/Grid.py +338 -0
- topologicpy/Helper.py +182 -0
- topologicpy/Honeybee.py +424 -0
- topologicpy/Matrix.py +255 -0
- topologicpy/Neo4jGraph.py +311 -0
- topologicpy/Plotly.py +1396 -0
- topologicpy/Polyskel.py +524 -0
- topologicpy/Process.py +1368 -0
- topologicpy/SQL.py +48 -0
- topologicpy/Shell.py +1418 -0
- topologicpy/Speckle.py +433 -0
- topologicpy/Topology.py +5854 -0
- topologicpy/UnitTest.py +29 -0
- topologicpy/Vector.py +555 -0
- topologicpy/Vertex.py +714 -0
- topologicpy/Wire.py +2346 -0
- topologicpy/__init__.py +20 -0
- topologicpy/bin/linux/topologic/__init__.py +2 -0
- topologicpy/bin/linux/topologic/topologic.cpython-310-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-311-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-38-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic/topologic.cpython-39-x86_64-linux-gnu.so +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBO-6bdf205d.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBRep-2960a069.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKBool-c44b74bd.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKFillet-9a670ba0.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG2d-8f31849e.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKG3d-4c6bce57.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomAlgo-26066fd9.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKGeomBase-2116cabe.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMath-72572fa8.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKMesh-2a060427.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKOffset-6cab68ff.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKPrim-eb1262b3.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKShHealing-e67e5cc7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKTopAlgo-e4c96c33.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libTKernel-fb7fe3b7.so.7.7.0 +0 -0
- topologicpy/bin/linux/topologic.libs/libgcc_s-32c1665e.so.1 +0 -0
- topologicpy/bin/linux/topologic.libs/libstdc++-672d7b41.so.6.0.30 +0 -0
- topologicpy/bin/windows/topologic/TKBO-f6b191de.dll +0 -0
- topologicpy/bin/windows/topologic/TKBRep-e56a600e.dll +0 -0
- topologicpy/bin/windows/topologic/TKBool-7b8d47ae.dll +0 -0
- topologicpy/bin/windows/topologic/TKFillet-0ddbf0a8.dll +0 -0
- topologicpy/bin/windows/topologic/TKG2d-2e2dee3d.dll +0 -0
- topologicpy/bin/windows/topologic/TKG3d-6674513d.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomAlgo-d240e370.dll +0 -0
- topologicpy/bin/windows/topologic/TKGeomBase-df87aba5.dll +0 -0
- topologicpy/bin/windows/topologic/TKMath-45bd625a.dll +0 -0
- topologicpy/bin/windows/topologic/TKMesh-d6e826b1.dll +0 -0
- topologicpy/bin/windows/topologic/TKOffset-79b9cc94.dll +0 -0
- topologicpy/bin/windows/topologic/TKPrim-aa430a86.dll +0 -0
- topologicpy/bin/windows/topologic/TKShHealing-bb48be89.dll +0 -0
- topologicpy/bin/windows/topologic/TKTopAlgo-7d0d1e22.dll +0 -0
- topologicpy/bin/windows/topologic/TKernel-08c8cfbb.dll +0 -0
- topologicpy/bin/windows/topologic/__init__.py +2 -0
- topologicpy/bin/windows/topologic/topologic.cp310-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp311-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp38-win_amd64.pyd +0 -0
- topologicpy/bin/windows/topologic/topologic.cp39-win_amd64.pyd +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/METADATA +1 -1
- topologicpy-0.4.9.dist-info/RECORD +77 -0
- topologicpy-0.4.9.dist-info/top_level.txt +1 -0
- topologicpy-0.4.8.dist-info/RECORD +0 -5
- topologicpy-0.4.8.dist-info/top_level.txt +0 -1
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/LICENSE +0 -0
- {topologicpy-0.4.8.dist-info → topologicpy-0.4.9.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import topologic
|
|
2
|
+
from topologic import IntAttribute, DoubleAttribute, StringAttribute, ListAttribute
|
|
3
|
+
|
|
4
|
+
class Dictionary(topologic.Dictionary):
|
|
5
|
+
'''
|
|
6
|
+
@staticmethod
|
|
7
|
+
def ByDGLData(item):
|
|
8
|
+
"""
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
item : TYPE
|
|
12
|
+
DESCRIPTION.
|
|
13
|
+
|
|
14
|
+
Returns
|
|
15
|
+
-------
|
|
16
|
+
dictionaries : TYPE
|
|
17
|
+
DESCRIPTION.
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
keys = list(item.keys())
|
|
21
|
+
vList = []
|
|
22
|
+
for k in keys:
|
|
23
|
+
vList.append(item[k].tolist())
|
|
24
|
+
dictionaries = []
|
|
25
|
+
for v in range(len(vList[0])):
|
|
26
|
+
values = []
|
|
27
|
+
for k in range(len(keys)):
|
|
28
|
+
value = vList[k][v]
|
|
29
|
+
values.append(value)
|
|
30
|
+
dictionaries.append(Dictionary.ByKeysValues(keys, values))
|
|
31
|
+
return dictionaries
|
|
32
|
+
'''
|
|
33
|
+
@staticmethod
|
|
34
|
+
def ByKeysValues(keys, values):
|
|
35
|
+
"""
|
|
36
|
+
Creates a Dictionary from the input list of keys and the input list of values.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
keys : list
|
|
41
|
+
A list of strings representing the keys of the dictionary.
|
|
42
|
+
values : list
|
|
43
|
+
A list of values corresponding to the list of keys. Values can be integers, floats, strings, or lists
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
topologic.Dictionary
|
|
48
|
+
The created dictionary.
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
if not isinstance(keys, list) or not isinstance(values, list):
|
|
52
|
+
return None
|
|
53
|
+
if len(keys) != len(values):
|
|
54
|
+
return None
|
|
55
|
+
stl_keys = []
|
|
56
|
+
stl_values = []
|
|
57
|
+
for i in range(len(keys)):
|
|
58
|
+
if isinstance(keys[i], str):
|
|
59
|
+
stl_keys.append(keys[i])
|
|
60
|
+
else:
|
|
61
|
+
stl_keys.append(str(keys[i]))
|
|
62
|
+
if isinstance(values[i], list) and len(values[i]) == 1:
|
|
63
|
+
value = values[i][0]
|
|
64
|
+
else:
|
|
65
|
+
value = values[i]
|
|
66
|
+
if isinstance(value, bool):
|
|
67
|
+
if value == False:
|
|
68
|
+
stl_values.append(topologic.IntAttribute(0))
|
|
69
|
+
else:
|
|
70
|
+
stl_values.append(topologic.IntAttribute(1))
|
|
71
|
+
elif isinstance(value, int):
|
|
72
|
+
stl_values.append(topologic.IntAttribute(value))
|
|
73
|
+
elif isinstance(value, float):
|
|
74
|
+
stl_values.append(topologic.DoubleAttribute(value))
|
|
75
|
+
elif isinstance(value, str):
|
|
76
|
+
stl_values.append(topologic.StringAttribute(value))
|
|
77
|
+
elif isinstance(value, list):
|
|
78
|
+
l = []
|
|
79
|
+
for v in value:
|
|
80
|
+
if isinstance(v, bool):
|
|
81
|
+
l.append(topologic.IntAttribute(v))
|
|
82
|
+
elif isinstance(v, int):
|
|
83
|
+
l.append(topologic.IntAttribute(v))
|
|
84
|
+
elif isinstance(v, float):
|
|
85
|
+
l.append(topologic.DoubleAttribute(v))
|
|
86
|
+
elif isinstance(v, str):
|
|
87
|
+
l.append(topologic.StringAttribute(v))
|
|
88
|
+
stl_values.append(topologic.ListAttribute(l))
|
|
89
|
+
else:
|
|
90
|
+
return None
|
|
91
|
+
return topologic.Dictionary.ByKeysValues(stl_keys, stl_values)
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def ByMergedDictionaries(dictionaries):
|
|
95
|
+
"""
|
|
96
|
+
Creates a dictionary by merging the list of input dictionaries.
|
|
97
|
+
|
|
98
|
+
Parameters
|
|
99
|
+
----------
|
|
100
|
+
dictionaries : list
|
|
101
|
+
The input list of dictionaries to be merges.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
topologic.DIctionary
|
|
106
|
+
The created dictionary.
|
|
107
|
+
|
|
108
|
+
"""
|
|
109
|
+
sinkKeys = []
|
|
110
|
+
sinkValues = []
|
|
111
|
+
d = dictionaries[0]
|
|
112
|
+
if d != None:
|
|
113
|
+
stlKeys = d.Keys()
|
|
114
|
+
if len(stlKeys) > 0:
|
|
115
|
+
sinkKeys = d.Keys()
|
|
116
|
+
sinkValues = Dictionary.Values(d)
|
|
117
|
+
for i in range(1,len(dictionaries)):
|
|
118
|
+
d = dictionaries[i]
|
|
119
|
+
if d == None:
|
|
120
|
+
continue
|
|
121
|
+
stlKeys = d.Keys()
|
|
122
|
+
if len(stlKeys) > 0:
|
|
123
|
+
sourceKeys = d.Keys()
|
|
124
|
+
for aSourceKey in sourceKeys:
|
|
125
|
+
if aSourceKey not in sinkKeys:
|
|
126
|
+
sinkKeys.append(aSourceKey)
|
|
127
|
+
sinkValues.append("")
|
|
128
|
+
for i in range(len(sourceKeys)):
|
|
129
|
+
index = sinkKeys.index(sourceKeys[i])
|
|
130
|
+
sourceValue = Dictionary.ValueAtKey(d,sourceKeys[i])
|
|
131
|
+
if sourceValue != None:
|
|
132
|
+
if sinkValues[index] != "":
|
|
133
|
+
if isinstance(sinkValues[index], list):
|
|
134
|
+
sinkValues[index].append(sourceValue)
|
|
135
|
+
else:
|
|
136
|
+
sinkValues[index] = [sinkValues[index], sourceValue]
|
|
137
|
+
else:
|
|
138
|
+
sinkValues[index] = sourceValue
|
|
139
|
+
if len(sinkKeys) > 0 and len(sinkValues) > 0:
|
|
140
|
+
newDict = Dictionary.ByKeysValues(sinkKeys, sinkValues)
|
|
141
|
+
return newDict
|
|
142
|
+
return None
|
|
143
|
+
'''
|
|
144
|
+
@staticmethod
|
|
145
|
+
def ByObjectProperties(bObject, keys, importAll):
|
|
146
|
+
"""
|
|
147
|
+
Parameters
|
|
148
|
+
----------
|
|
149
|
+
bObject : TYPE
|
|
150
|
+
DESCRIPTION.
|
|
151
|
+
keys : TYPE
|
|
152
|
+
DESCRIPTION.
|
|
153
|
+
importAll : TYPE
|
|
154
|
+
DESCRIPTION.
|
|
155
|
+
|
|
156
|
+
Raises
|
|
157
|
+
------
|
|
158
|
+
Exception
|
|
159
|
+
DESCRIPTION.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
TYPE
|
|
164
|
+
DESCRIPTION.
|
|
165
|
+
|
|
166
|
+
"""
|
|
167
|
+
# bObject, keys, importAll = item
|
|
168
|
+
dictKeys = []
|
|
169
|
+
dictValues = []
|
|
170
|
+
|
|
171
|
+
if importAll:
|
|
172
|
+
dictKeys.append("Name")
|
|
173
|
+
dictValues.append(bObject.name)
|
|
174
|
+
dictKeys.append("Color")
|
|
175
|
+
dictValues.append([bObject.color[0], bObject.color[1], bObject.color[2], bObject.color[3]])
|
|
176
|
+
dictKeys.append("Location")
|
|
177
|
+
dictValues.append([bObject.location[0], bObject.location[1], bObject.location[2]])
|
|
178
|
+
dictKeys.append("Scale")
|
|
179
|
+
dictValues.append([bObject.scale[0], bObject.scale[1], bObject.scale[2]])
|
|
180
|
+
dictKeys.append("Rotation")
|
|
181
|
+
dictValues.append([bObject.rotation_euler[0], bObject.rotation_euler[1], bObject.rotation_euler[2]])
|
|
182
|
+
dictKeys.append("Dimensions")
|
|
183
|
+
dictValues.append([bObject.dimensions[0], bObject.dimensions[1], bObject.dimensions[2]])
|
|
184
|
+
for k, v in bObject.items():
|
|
185
|
+
if isinstance(v, bool) or isinstance(v, int) or isinstance(v, float) or isinstance(v, str):
|
|
186
|
+
dictKeys.append(str(k))
|
|
187
|
+
dictValues.append(v)
|
|
188
|
+
else:
|
|
189
|
+
for k in keys:
|
|
190
|
+
try:
|
|
191
|
+
v = bObject[k]
|
|
192
|
+
if v:
|
|
193
|
+
if isinstance(v, bool) or isinstance(v, int) or isinstance(v, float) or isinstance(v, str):
|
|
194
|
+
dictKeys.append(str(k))
|
|
195
|
+
dictValues.append(v)
|
|
196
|
+
except:
|
|
197
|
+
if k.lower() == "name":
|
|
198
|
+
dictKeys.append("Name")
|
|
199
|
+
dictValues.append(bObject.name)
|
|
200
|
+
elif k.lower() == "color":
|
|
201
|
+
dictKeys.append("Color")
|
|
202
|
+
dictValues.append([bObject.color[0], bObject.color[1], bObject.color[2], bObject.color[3]])
|
|
203
|
+
elif k.lower() == "location":
|
|
204
|
+
dictKeys.append("Location")
|
|
205
|
+
dictValues.append([bObject.location[0], bObject.location[1], bObject.location[2]])
|
|
206
|
+
elif k.lower() == "scale":
|
|
207
|
+
dictKeys.append("Scale")
|
|
208
|
+
dictValues.append([bObject.scale[0], bObject.scale[1], bObject.scale[2]])
|
|
209
|
+
elif k.lower() == "rotation":
|
|
210
|
+
dictKeys.append("Rotation")
|
|
211
|
+
dictValues.append([bObject.rotation_euler[0], bObject.rotation_euler[1], bObject.rotation_euler[2]])
|
|
212
|
+
elif k.lower() == "dimensions":
|
|
213
|
+
dictKeys.append("Dimensions")
|
|
214
|
+
dictValues.append([bObject.dimensions[0], bObject.dimensions[1], bObject.dimensions[2]])
|
|
215
|
+
else:
|
|
216
|
+
raise Exception("Dictionary.ByObjectProperties: Key \""+k+"\" does not exist in the properties of object \""+bObject.name+"\".")
|
|
217
|
+
|
|
218
|
+
return Dictionary.ByKeysValues(dictKeys, dictValues)
|
|
219
|
+
'''
|
|
220
|
+
|
|
221
|
+
@staticmethod
|
|
222
|
+
def ByPythonDictionary(pythonDictionary):
|
|
223
|
+
"""
|
|
224
|
+
Creates a dictionary equivalent to the input python dictionary.
|
|
225
|
+
|
|
226
|
+
Parameters
|
|
227
|
+
----------
|
|
228
|
+
pythonDictionary : dict
|
|
229
|
+
The input python dictionary.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
topologic.Dictionary
|
|
234
|
+
The dictionary equivalent to the input python dictionary.
|
|
235
|
+
|
|
236
|
+
"""
|
|
237
|
+
if not isinstance(pythonDictionary, dict):
|
|
238
|
+
return None
|
|
239
|
+
keys = list(pythonDictionary.keys())
|
|
240
|
+
values = []
|
|
241
|
+
for key in keys:
|
|
242
|
+
values.append(pythonDictionary[key])
|
|
243
|
+
return Dictionary.ByKeysValues(keys, values)
|
|
244
|
+
|
|
245
|
+
@staticmethod
|
|
246
|
+
def Keys(dictionary):
|
|
247
|
+
"""
|
|
248
|
+
Returns the keys of the input dictionary.
|
|
249
|
+
|
|
250
|
+
Parameters
|
|
251
|
+
----------
|
|
252
|
+
dictionary : topologic.Dictionary or dict
|
|
253
|
+
The input dictionary.
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
list
|
|
258
|
+
The list of keys of the input dictionary.
|
|
259
|
+
|
|
260
|
+
"""
|
|
261
|
+
if isinstance(dictionary, dict):
|
|
262
|
+
return list(dictionary.keys())
|
|
263
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
|
264
|
+
return dictionary.Keys()
|
|
265
|
+
else:
|
|
266
|
+
return None
|
|
267
|
+
|
|
268
|
+
@staticmethod
|
|
269
|
+
def ListAttributeValues(listAttribute):
|
|
270
|
+
"""
|
|
271
|
+
Returns the list of values embedded in the input listAttribute.
|
|
272
|
+
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
listAttribute : listAttribute
|
|
276
|
+
The input list attribute.
|
|
277
|
+
|
|
278
|
+
Returns
|
|
279
|
+
-------
|
|
280
|
+
list
|
|
281
|
+
The list of values found in the input list attribute
|
|
282
|
+
|
|
283
|
+
"""
|
|
284
|
+
listAttributes = listAttribute.ListValue()
|
|
285
|
+
returnList = []
|
|
286
|
+
for attr in listAttributes:
|
|
287
|
+
if isinstance(attr, IntAttribute):
|
|
288
|
+
returnList.append(attr.IntValue())
|
|
289
|
+
elif isinstance(attr, DoubleAttribute):
|
|
290
|
+
returnList.append(attr.DoubleValue())
|
|
291
|
+
elif isinstance(attr, StringAttribute):
|
|
292
|
+
returnList.append(attr.StringValue())
|
|
293
|
+
elif isinstance(attr, float) or isinstance(attr, int) or isinstance(attr, str) or isinstance(attr, dict):
|
|
294
|
+
returnList.append(attr)
|
|
295
|
+
return returnList
|
|
296
|
+
|
|
297
|
+
@staticmethod
|
|
298
|
+
def PythonDictionary(dictionary):
|
|
299
|
+
"""
|
|
300
|
+
Returns the input dictionary as a python dictionary
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
dicitonary : topologic.Dictionary
|
|
305
|
+
The input dictionary.
|
|
306
|
+
|
|
307
|
+
Returns
|
|
308
|
+
-------
|
|
309
|
+
dict
|
|
310
|
+
The python dictionary equivalent of the input dictionary
|
|
311
|
+
|
|
312
|
+
"""
|
|
313
|
+
if not isinstance(dictionary, topologic.Dictionary):
|
|
314
|
+
return None
|
|
315
|
+
keys = dictionary.Keys()
|
|
316
|
+
pythonDict = {}
|
|
317
|
+
for key in keys:
|
|
318
|
+
try:
|
|
319
|
+
attr = dictionary.ValueAtKey(key)
|
|
320
|
+
except:
|
|
321
|
+
raise Exception("Dictionary.Values - Error: Could not retrieve a Value at the specified key ("+key+")")
|
|
322
|
+
if isinstance(attr, topologic.IntAttribute):
|
|
323
|
+
pythonDict[key] = (attr.IntValue())
|
|
324
|
+
elif isinstance(attr, topologic.DoubleAttribute):
|
|
325
|
+
pythonDict[key] = (attr.DoubleValue())
|
|
326
|
+
elif isinstance(attr, topologic.StringAttribute):
|
|
327
|
+
pythonDict[key] = (attr.StringValue())
|
|
328
|
+
elif isinstance(attr, topologic.ListAttribute):
|
|
329
|
+
pythonDict[key] = (Dictionary.ListAttributeValues(attr))
|
|
330
|
+
else:
|
|
331
|
+
pythonDict[key]=("")
|
|
332
|
+
return pythonDict
|
|
333
|
+
|
|
334
|
+
@staticmethod
|
|
335
|
+
def SetValueAtKey(dictionary, key, value):
|
|
336
|
+
"""
|
|
337
|
+
Creates a key/value pair in the input dictionary.
|
|
338
|
+
|
|
339
|
+
Parameters
|
|
340
|
+
----------
|
|
341
|
+
dicitonary : topologic.Dictionary or dict
|
|
342
|
+
The input dictionary.
|
|
343
|
+
key : string
|
|
344
|
+
The input key.
|
|
345
|
+
value : int , float , string, or list
|
|
346
|
+
The value associated with the key.
|
|
347
|
+
|
|
348
|
+
Returns
|
|
349
|
+
-------
|
|
350
|
+
topologic.Dictionary or dict
|
|
351
|
+
The input dictionary with the key/value pair added to it.
|
|
352
|
+
|
|
353
|
+
"""
|
|
354
|
+
def processPythonDictionary (dictionary, key, value):
|
|
355
|
+
dictionary[key] = value
|
|
356
|
+
return dictionary
|
|
357
|
+
|
|
358
|
+
def processTopologicDictionary(dictionary, key, value):
|
|
359
|
+
keys = dictionary.Keys()
|
|
360
|
+
if not key in keys:
|
|
361
|
+
keys.append(key)
|
|
362
|
+
values = []
|
|
363
|
+
for k in keys:
|
|
364
|
+
if k == key:
|
|
365
|
+
values.append(value)
|
|
366
|
+
else:
|
|
367
|
+
values.append(Dictionary.ValueAtKey(dictionary, k))
|
|
368
|
+
return Dictionary.ByKeysValues(keys, values)
|
|
369
|
+
|
|
370
|
+
if isinstance(dictionary, dict):
|
|
371
|
+
return processPythonDictionary(dictionary, key, value)
|
|
372
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
|
373
|
+
return processTopologicDictionary(dictionary, key, value)
|
|
374
|
+
else:
|
|
375
|
+
return None
|
|
376
|
+
|
|
377
|
+
@staticmethod
|
|
378
|
+
def ValueAtKey(dictionary, key):
|
|
379
|
+
"""
|
|
380
|
+
Returns the value of the input key in the input dictionary.
|
|
381
|
+
|
|
382
|
+
Parameters
|
|
383
|
+
----------
|
|
384
|
+
dictionary : topologic.Dictionary or dict
|
|
385
|
+
The input dictionary.
|
|
386
|
+
key : string
|
|
387
|
+
The input key.
|
|
388
|
+
|
|
389
|
+
Returns
|
|
390
|
+
-------
|
|
391
|
+
int , float, string, list , or dict
|
|
392
|
+
The value found at the input key in the input dictionary.
|
|
393
|
+
|
|
394
|
+
"""
|
|
395
|
+
if isinstance(dictionary, dict):
|
|
396
|
+
attr = dictionary[key]
|
|
397
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
|
398
|
+
attr = dictionary.ValueAtKey(key)
|
|
399
|
+
else:
|
|
400
|
+
return None
|
|
401
|
+
|
|
402
|
+
if isinstance(attr, IntAttribute):
|
|
403
|
+
return (attr.IntValue())
|
|
404
|
+
elif isinstance(attr, DoubleAttribute):
|
|
405
|
+
return (attr.DoubleValue())
|
|
406
|
+
elif isinstance(attr, StringAttribute):
|
|
407
|
+
return (attr.StringValue())
|
|
408
|
+
elif isinstance(attr, ListAttribute):
|
|
409
|
+
return (Dictionary.ListAttributeValues(attr))
|
|
410
|
+
elif isinstance(attr, float) or isinstance(attr, int) or isinstance(attr, str):
|
|
411
|
+
return attr
|
|
412
|
+
elif isinstance(attr, list):
|
|
413
|
+
return Dictionary.ListAttributeValues(attr)
|
|
414
|
+
elif isinstance(attr, dict):
|
|
415
|
+
return attr
|
|
416
|
+
else:
|
|
417
|
+
return None
|
|
418
|
+
|
|
419
|
+
@staticmethod
|
|
420
|
+
def Values(dictionary):
|
|
421
|
+
"""
|
|
422
|
+
Returns the list of values in the input dictionary.
|
|
423
|
+
|
|
424
|
+
Parameters
|
|
425
|
+
----------
|
|
426
|
+
dictionary : topologic.Dictionary or dict
|
|
427
|
+
The input dictionary.
|
|
428
|
+
|
|
429
|
+
Returns
|
|
430
|
+
-------
|
|
431
|
+
list
|
|
432
|
+
The list of values found in the input dictionary.
|
|
433
|
+
|
|
434
|
+
"""
|
|
435
|
+
keys = None
|
|
436
|
+
if isinstance(dictionary, dict):
|
|
437
|
+
keys = dictionary.keys()
|
|
438
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
|
439
|
+
keys = dictionary.Keys()
|
|
440
|
+
returnList = []
|
|
441
|
+
if not keys:
|
|
442
|
+
return None
|
|
443
|
+
for key in keys:
|
|
444
|
+
try:
|
|
445
|
+
if isinstance(dictionary, dict):
|
|
446
|
+
attr = dictionary[key]
|
|
447
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
|
448
|
+
attr = dictionary.ValueAtKey(key)
|
|
449
|
+
else:
|
|
450
|
+
attr = None
|
|
451
|
+
except:
|
|
452
|
+
return None
|
|
453
|
+
if isinstance(attr, topologic.IntAttribute):
|
|
454
|
+
returnList.append(attr.IntValue())
|
|
455
|
+
elif isinstance(attr, topologic.DoubleAttribute):
|
|
456
|
+
returnList.append(attr.DoubleValue())
|
|
457
|
+
elif isinstance(attr, topologic.StringAttribute):
|
|
458
|
+
returnList.append(attr.StringValue())
|
|
459
|
+
elif isinstance(attr, topologic.ListAttribute):
|
|
460
|
+
returnList.append(Dictionary.ListAttributeValues(attr))
|
|
461
|
+
elif isinstance(attr, float) or isinstance(attr, int) or isinstance(attr, str):
|
|
462
|
+
returnList.append(attr)
|
|
463
|
+
elif isinstance(attr, list):
|
|
464
|
+
returnList.append(Dictionary.ListAttributeValues(attr))
|
|
465
|
+
else:
|
|
466
|
+
returnList.append("")
|
|
467
|
+
return returnList
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|