Skip to content

Commit 9eb34a9

Browse files
Merge pull request #538 from sheilatron/Docstrings4Learning
Improve docstring for NameID and argtree.add_path
2 parents 7135d98 + 40c5452 commit 9eb34a9

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/saml2/argtree.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,34 @@ def set_arg(cls, arg, value):
5353

5454
def add_path(tdict, path):
5555
"""
56+
Create or extend an argument tree `tdict` from `path`.
5657
5758
:param tdict: a dictionary representing a argument tree
5859
:param path: a path list
5960
: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'}
6084
"""
6185
t = tdict
6286
for step in path[:-2]:

src/saml2/saml.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,16 @@ def base_id_from_string(xml_string):
811811

812812

813813
class NameID(NameIDType_):
814-
"""The urn:oasis:names:tc:SAML:2.0:assertion:NameID element """
814+
"""The urn:oasis:names:tc:SAML:2.0:assertion:NameID element
815+
816+
From the Oasis SAML2 Technical Overview:
817+
818+
"The <NameID> element within a <Subject> offers the ability to provide name
819+
identifiers in a number of different formats. SAML's predefined formats
820+
include: Email address, X.509 subject name, Windows domain qualified name,
821+
Kerberos principal name, Entity identifier, Persistent identifier,
822+
Transient identifier."
823+
"""
815824

816825
c_tag = 'NameID'
817826
c_namespace = NAMESPACE

0 commit comments

Comments
 (0)