From 7d668de1692c1f29f94d293ae7ba22e5bcc837bf Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 19 Jan 2013 16:50:17 +0400 Subject: [PATCH] Raise TypeError only if it is segment type that has problems It raised TypeError also when module did not have required function --- powerline/segments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerline/segments.py b/powerline/segments.py index e2be730c..d9c1d878 100644 --- a/powerline/segments.py +++ b/powerline/segments.py @@ -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,