topologicpy 0.5.5__py3-none-any.whl → 0.5.7__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/Dictionary.py +51 -0
- topologicpy/Graph.py +478 -244
- topologicpy/__init__.py +1 -1
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/METADATA +2 -1
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/RECORD +8 -8
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/LICENSE +0 -0
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/WHEEL +0 -0
- {topologicpy-0.5.5.dist-info → topologicpy-0.5.7.dist-info}/top_level.txt +0 -0
topologicpy/Dictionary.py
CHANGED
@@ -415,6 +415,57 @@ class Dictionary(topologic.Dictionary):
|
|
415
415
|
pythonDict[key]=("")
|
416
416
|
return pythonDict
|
417
417
|
|
418
|
+
@staticmethod
|
419
|
+
def RemoveKey(dictionary, key):
|
420
|
+
"""
|
421
|
+
Removes the key (and its associated value) from the input dictionary.
|
422
|
+
|
423
|
+
Parameters
|
424
|
+
----------
|
425
|
+
dictionary : topologic.Dictionary or dict
|
426
|
+
The input dictionary.
|
427
|
+
key : string
|
428
|
+
The input key.
|
429
|
+
|
430
|
+
Returns
|
431
|
+
-------
|
432
|
+
topologic.Dictionary or dict
|
433
|
+
The input dictionary with the key/value removed from it.
|
434
|
+
|
435
|
+
"""
|
436
|
+
def processPythonDictionary (dictionary, key):
|
437
|
+
values = []
|
438
|
+
keys = dictionary.keys()
|
439
|
+
new_dict = {}
|
440
|
+
for k in keys:
|
441
|
+
if not key.lower() == k.lower():
|
442
|
+
new_dict[key] = dictionary[key]
|
443
|
+
return new_dict
|
444
|
+
|
445
|
+
def processTopologicDictionary(dictionary, key):
|
446
|
+
keys = dictionary.Keys()
|
447
|
+
new_keys = []
|
448
|
+
new_values = []
|
449
|
+
for k in keys:
|
450
|
+
if not key.lower() == k.lower():
|
451
|
+
new_keys.append(k)
|
452
|
+
new_values.append(Dictionary.ValueAtKey(dictionary, k))
|
453
|
+
return Dictionary.ByKeysValues(new_keys, new_values)
|
454
|
+
|
455
|
+
if not isinstance(dictionary, topologic.Dictionary) and not isinstance(dictionary, dict):
|
456
|
+
print("Dictionary.RemoveKey - Error: The input dictionary parameter is not a valid topologic or python dictionary. Returning None.")
|
457
|
+
return None
|
458
|
+
if not isinstance(key, str):
|
459
|
+
print("Dictionary.RemoveKey - Error: The input key parameter is not a valid string. Returning None.")
|
460
|
+
return None
|
461
|
+
|
462
|
+
if isinstance(dictionary, dict):
|
463
|
+
return processPythonDictionary(dictionary, key)
|
464
|
+
elif isinstance(dictionary, topologic.Dictionary):
|
465
|
+
return processTopologicDictionary(dictionary, key)
|
466
|
+
else:
|
467
|
+
return None
|
468
|
+
|
418
469
|
@staticmethod
|
419
470
|
def SetValueAtKey(dictionary, key, value):
|
420
471
|
"""
|