@@ -53,10 +53,34 @@ def set_arg(cls, arg, value):
53
53
54
54
def add_path (tdict , path ):
55
55
"""
56
+ Create or extend an argument tree `tdict` from `path`.
56
57
57
58
:param tdict: a dictionary representing a argument tree
58
59
:param path: a path list
59
60
:return: a dictionary
61
+
62
+ Convert a list of items in a 'path' into a nested dict, where the
63
+ second to last item becomes the key for the final item. The remaining
64
+ items in the path become keys in the nested dict around that final pair
65
+ of items.
66
+
67
+ For example, for input values of:
68
+ tdict={}
69
+ path = ['assertion', 'subject', 'subject_confirmation',
70
+ 'method', 'urn:oasis:names:tc:SAML:2.0:cm:bearer']
71
+
72
+ Returns an output value of:
73
+ {'assertion': {'subject': {'subject_confirmation':
74
+ {'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'}}}}
75
+
76
+ Another example, this time with a non-empty tdict input:
77
+
78
+ tdict={'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'},
79
+ path=['subject_confirmation_data', 'in_response_to', '_012345']
80
+
81
+ Returns an output value of:
82
+ {'subject_confirmation_data': {'in_response_to': '_012345'},
83
+ 'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'}
60
84
"""
61
85
t = tdict
62
86
for step in path [:- 2 ]:
0 commit comments