Skip to content

Commit 36b574a

Browse files
committed
Normalize duplicate code for to_local function
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent cf529b6 commit 36b574a

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

src/saml2/attribute_converter.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -118,42 +118,7 @@ def to_local(acs, statement, allow_unknown_attributes=False):
118118
:param allow_unknown_attributes: If unknown attributes are allowed
119119
:return: A key,values dictionary
120120
"""
121-
if not acs:
122-
acs = [AttributeConverter()]
123-
acsd = {"": acs}
124-
else:
125-
acsd = dict([(a.name_format, a) for a in acs])
126-
127-
ava = {}
128-
for attr in statement.attribute:
129-
try:
130-
_func = acsd[attr.name_format].ava_from
131-
except KeyError:
132-
if attr.name_format == NAME_FORMAT_UNSPECIFIED or \
133-
allow_unknown_attributes:
134-
_func = acs[0].lcd_ava_from
135-
else:
136-
logger.info("Unsupported attribute name format: %s",
137-
attr.name_format)
138-
continue
139-
140-
try:
141-
key, val = _func(attr)
142-
except KeyError:
143-
if allow_unknown_attributes:
144-
key, val = acs[0].lcd_ava_from(attr)
145-
else:
146-
logger.info("Unknown attribute name: %s", attr)
147-
continue
148-
except AttributeError:
149-
continue
150-
151-
try:
152-
ava[key].extend(val)
153-
except KeyError:
154-
ava[key] = val
155-
156-
return ava
121+
return list_to_local(acs, statement.attribute, allow_unknown_attributes)
157122

158123

159124
def list_to_local(acs, attrlist, allow_unknown_attributes=False):

0 commit comments

Comments
 (0)