Raise TypeError only if it is segment type that has problems

It raised TypeError also when module did not have required function
This commit is contained in:
ZyX 2013-01-19 16:50:17 +04:00 committed by Kim Silkebækken
parent 06d4b4555f
commit 7d668de169
1 changed files with 2 additions and 1 deletions

View File

@ -30,9 +30,10 @@ class Segments(object):
def get(self, segment, side):
segment_type = segment.get('type', 'function')
try:
contents, contents_func, key = getattr(self, 'get_{0}'.format(segment_type))(segment)
get_segment_info = getattr(self, 'get_{0}'.format(segment_type))
except AttributeError:
raise TypeError('Unknown segment type: {0}'.format(segment_type))
contents, contents_func, key = get_segment_info(segment)
highlighting_group = segment.get('highlight', segment.get('name'))
return {
'key': key,