@@ -118,42 +118,7 @@ def to_local(acs, statement, allow_unknown_attributes=False):
118
118
:param allow_unknown_attributes: If unknown attributes are allowed
119
119
:return: A key,values dictionary
120
120
"""
121
- if not acs :
122
- acs = [AttributeConverter ()]
123
- acsd = {"" : acs }
124
- else :
125
- acsd = dict ([(a .name_format , a ) for a in acs ])
126
-
127
- ava = {}
128
- for attr in statement .attribute :
129
- try :
130
- _func = acsd [attr .name_format ].ava_from
131
- except KeyError :
132
- if attr .name_format == NAME_FORMAT_UNSPECIFIED or \
133
- allow_unknown_attributes :
134
- _func = acs [0 ].lcd_ava_from
135
- else :
136
- logger .info ("Unsupported attribute name format: %s" ,
137
- attr .name_format )
138
- continue
139
-
140
- try :
141
- key , val = _func (attr )
142
- except KeyError :
143
- if allow_unknown_attributes :
144
- key , val = acs [0 ].lcd_ava_from (attr )
145
- else :
146
- logger .info ("Unknown attribute name: %s" , attr )
147
- continue
148
- except AttributeError :
149
- continue
150
-
151
- try :
152
- ava [key ].extend (val )
153
- except KeyError :
154
- ava [key ] = val
155
-
156
- return ava
121
+ return list_to_local (acs , statement .attribute , allow_unknown_attributes )
157
122
158
123
159
124
def list_to_local (acs , attrlist , allow_unknown_attributes = False ):
@@ -313,23 +278,15 @@ def from_dict(self, mapdict):
313
278
314
279
def lcd_ava_from (self , attribute ):
315
280
"""
316
- In nothing else works, this should
281
+ If nothing else works, this should
317
282
318
- :param attribute: An Attribute Instance
283
+ :param attribute: an Attribute instance
319
284
:return:
320
285
"""
321
- try :
322
- name = attribute .friendly_name .strip ()
323
- except AttributeError :
324
- name = attribute .name .strip ()
325
-
326
- values = []
327
- for value in attribute .attribute_value :
328
- if not value .text :
329
- values .append ('' )
330
- else :
331
- values .append (value .text .strip ())
332
-
286
+ name = attribute .name .strip ()
287
+ values = [
288
+ (value .text or '' ).strip ()
289
+ for value in attribute .attribute_value ]
333
290
return name , values
334
291
335
292
def fail_safe_fro (self , statement ):
0 commit comments