-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scope remover processor #132
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from ..attribute_processor import AttributeProcessorError | ||
from .base_processor import BaseProcessor | ||
|
||
class ScopeRemoverProcessor(BaseProcessor): | ||
""" | ||
Removes the scope from a given attribute | ||
|
||
""" | ||
def process(self, internal_data, attribute, **kwargs): | ||
attributes = internal_data.attributes | ||
new_values = [] | ||
for value in attributes.get(attribute, [None]): | ||
if '@' in value: | ||
new_values.append(value.split('@')[0]) | ||
attributes[attribute] = new_values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will remove any attribute values without a If this was not intentional you only need to remove the for value in attributes.get(attribute, [None]):
value_with_no_scope = value.split('@')[0]
new_values.append(value_with_no_scope) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that the deployer uses this microservice for attributes that are scoped. I agree though that removing the attribute entirely in case it is not scoped, doesn't make much sense and will just add to confusion. I will revisit this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
attribute
is not found,[None]
will be returned andvalue
will be set toNone
. Thenvalue.split()
will fail. We should probably check if the attribute is there, and then process the values. If attribute is not there, I would raise anAttributeProcessorWarning
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!