Skip to content

Commit fe7a267

Browse files
Merge pull request #132 from jkakavas/add_scope_remover
Add scope remover processor
2 parents 9f39965 + ebca2e4 commit fe7a267

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from ..attribute_processor import AttributeProcessorError, AttributeProcessorWarning
2+
from .base_processor import BaseProcessor
3+
4+
class ScopeRemoverProcessor(BaseProcessor):
5+
"""
6+
Removes the scope from all values of a given attribute
7+
8+
"""
9+
def process(self, internal_data, attribute, **kwargs):
10+
attributes = internal_data.attributes
11+
new_values = []
12+
values = attributes.get(attribute, [])
13+
if not values:
14+
raise AttributeProcessorWarning("Attribute {} has no values".format(attribute))
15+
for value in values:
16+
unscoped_value = value.split('@')[0]
17+
new_values.append(unscoped_value)
18+
attributes[attribute] = new_values

0 commit comments

Comments
 (0)