@@ -9,8 +9,9 @@ def _config(f, requester, provider):
9
9
return rf .items ()
10
10
11
11
class MustachAttrValue (object ):
12
- def __init__ (self ,values ):
13
- self .values = values
12
+ def __init__ (self , attr_name , values ):
13
+ self ._attr_name = attr_name
14
+ self ._values = values
14
15
if any (['@' in v for v in values ]):
15
16
local_parts = []
16
17
domain_parts = []
@@ -26,19 +27,23 @@ def __init__(self,values):
26
27
self ._scopes = None
27
28
28
29
def __str__ (self ):
29
- return ";" .join (self .values )
30
+ return ";" .join (self ._values )
31
+
32
+ @property
33
+ def values (self ):
34
+ [{self ._attr_name : v } for v in self ._values ]
30
35
31
36
@property
32
37
def value (self ):
33
- if 1 == len (self .values ):
34
- return self .values [0 ]
38
+ if 1 == len (self ._values ):
39
+ return self ._values [0 ]
35
40
else :
36
- return self .values
41
+ return self ._values
37
42
38
43
@property
39
44
def first (self ):
40
- if len (self .values ) > 0 :
41
- return self .values [0 ]
45
+ if len (self ._values ) > 0 :
46
+ return self ._values [0 ]
42
47
else :
43
48
return ""
44
49
@@ -63,13 +68,13 @@ def _synthesize(self, attributes, requester, provider):
63
68
context = dict ()
64
69
65
70
for attr_name ,values in attributes .items ():
66
- context [attr_name ] = MustachAttrValue (values )
71
+ context [attr_name ] = MustachAttrValue (attr_name , values )
67
72
68
73
recipes = _config (self .synthetic_attributes , requester , provider )
69
74
print (context )
70
75
for attr_name , fmt in recipes :
71
76
print (fmt )
72
- syn_attributes [attr_name ] = re .split ("[;\n ]+" , pystache .render (fmt , context ))
77
+ syn_attributes [attr_name ] = [ v . strip (). strip ( ';' ) for v in re .split ("[;\n ]+" , pystache .render (fmt , context ))]
73
78
print (syn_attributes )
74
79
return syn_attributes
75
80
0 commit comments