-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from jkakavas/add_scope_remover
Add scope remover processor
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/satosa/micro_services/processors/scope_remover_processor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from ..attribute_processor import AttributeProcessorError, AttributeProcessorWarning | ||
from .base_processor import BaseProcessor | ||
|
||
class ScopeRemoverProcessor(BaseProcessor): | ||
""" | ||
Removes the scope from all values of a given attribute | ||
""" | ||
def process(self, internal_data, attribute, **kwargs): | ||
attributes = internal_data.attributes | ||
new_values = [] | ||
values = attributes.get(attribute, []) | ||
if not values: | ||
raise AttributeProcessorWarning("Attribute {} has no values".format(attribute)) | ||
for value in values: | ||
unscoped_value = value.split('@')[0] | ||
new_values.append(unscoped_value) | ||
attributes[attribute] = new_values |