Skip to content

Commit 4545eaf

Browse files
author
Ric Janus Sapasap
committed
Fix attribute_mapping.py
1 parent 544e52e commit 4545eaf

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/satosa/attribute_mapping.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def to_internal_filter(self, attribute_profile, external_attribute_names):
5757
:type case_insensitive: bool
5858
:rtype: list[str]
5959
60-
:param attribute_profile: From which external type to convert (ex: oidc, saml, ...)
60+
:param attribute_profile: From which external type to convert
61+
(ex: oidc, saml, ...)
6162
:param external_attribute_names: A list of attribute names
6263
:param case_insensitive: Create a case insensitive filter
6364
:return: A list of attribute names in the internal format
@@ -92,27 +93,32 @@ def to_internal(self, attribute_profile, external_dict):
9293
:type external_dict: dict[str, str]
9394
:rtype: dict[str, str]
9495
95-
:param attribute_profile: From which external type to convert (ex: oidc, saml, ...)
96+
:param attribute_profile: From which external type to convert
97+
(ex: oidc, saml, ...)
9698
:param external_dict: Attributes in the external format
9799
:return: Attributes in the internal format
98100
"""
99101
internal_dict = {}
100102

101103
for internal_attribute_name, mapping in self.from_internal_attributes.items():
102104
if attribute_profile not in mapping:
103-
logline = "no attribute mapping found for internal attribute {internal} the attribute profile {attribute}".format(
104-
internal=internal_attribute_name, attribute=attribute_profile
105-
)
105+
logline = (
106+
"no attribute mapping found for internal attribute"
107+
" {internal} the attribute profile {attribute}"
108+
).format(internal=internal_attribute_name, attribute=attribute_profile)
106109
logger.debug(logline)
107-
# skip this internal attribute if we have no mapping in the specified profile
110+
# skip this internal attribute if we have no mapping in
111+
# the specified profile
108112
continue
109113

110114
external_attribute_name = mapping[attribute_profile]
111115
attribute_values = self._collate_attribute_values_by_priority_order(
112116
external_attribute_name, external_dict
113117
)
114118
if attribute_values: # Only insert key if it has some values
115-
logline = "backend attribute {external} mapped to {internal} ({value})".format(
119+
logline = (
120+
"backend attribute {external} mapped to {internal}" " ({value})"
121+
).format(
116122
external=external_attribute_name,
117123
internal=internal_attribute_name,
118124
value=attribute_values,
@@ -158,7 +164,8 @@ def _handle_template_attributes(self, attribute_profile, internal_dict):
158164

159165
for internal_attribute_name, mapping in self.template_attributes.items():
160166
if attribute_profile not in mapping:
161-
# skip this internal attribute if we have no mapping in the specified profile
167+
# skip this internal attribute if we have no mapping in
168+
# the specified profile
162169
continue
163170

164171
external_attribute_name = mapping[attribute_profile]
@@ -211,7 +218,8 @@ def from_internal(self, attribute_profile, internal_dict):
211218
:type internal_dict: dict[str, str]
212219
:rtype: dict[str, str]
213220
214-
:param attribute_profile: To which external type to convert (ex: oidc, saml, ...)
221+
:param attribute_profile: From which external type to convert
222+
(ex: oidc, saml, ...)
215223
:param internal_dict: attributes to map
216224
:return: attribute values and names in the specified "profile"
217225
"""
@@ -231,10 +239,12 @@ def from_internal(self, attribute_profile, internal_dict):
231239
continue
232240

233241
if attribute_profile not in attribute_mapping:
234-
# skip this internal attribute if we have no mapping in the specified profile
235-
logline = "no mapping found for '{internal}' in attribute profile '{attribute}'".format(
236-
internal=internal_attribute_name, attribute=attribute_profile
237-
)
242+
# skip this internal attribute if we have no mapping in
243+
# the specified profile
244+
logline = (
245+
"no mapping found for '{internal}' in attribute profile"
246+
" '{attribute}'"
247+
).format(internal=internal_attribute_name, attribute=attribute_profile)
238248
logger.debug(logline)
239249
continue
240250

0 commit comments

Comments
 (0)