Remove recursion when checking segments

This commit is contained in:
Foo 2015-05-17 14:45:49 +03:00
parent f5d85b7294
commit bfd9a21bbb

View File

@ -198,10 +198,8 @@ args_spec = Spec(
segment_info=Spec().error('Segment info dictionary must be set by powerline').optional(), segment_info=Spec().error('Segment info dictionary must be set by powerline').optional(),
).unknown_spec(Spec(), Spec()).optional().copy ).unknown_spec(Spec(), Spec()).optional().copy
segment_module_spec = Spec().type(unicode).func(check_segment_module).optional().copy segment_module_spec = Spec().type(unicode).func(check_segment_module).optional().copy
sub_segments_spec = Spec()
exinclude_spec = Spec().re(function_name_re).func(check_exinclude_function).copy exinclude_spec = Spec().re(function_name_re).func(check_exinclude_function).copy
segment_spec = Spec( segment_spec_base = Spec(
type=Spec().oneof(type_keys).optional(),
name=Spec().re('^[a-zA-Z_]\w*$').optional(), name=Spec().re('^[a-zA-Z_]\w*$').optional(),
function=Spec().re(function_name_re).func(check_segment_function).optional(), function=Spec().re(function_name_re).func(check_segment_function).optional(),
exclude_modes=Spec().list(vim_mode_spec()).optional(), exclude_modes=Spec().list(vim_mode_spec()).optional(),
@ -230,10 +228,14 @@ segment_spec = Spec(
':divider$', ':divider$',
(lambda value: 'it is recommended that divider highlight group names end with ":divider"') (lambda value: 'it is recommended that divider highlight group names end with ":divider"')
).optional(), ).optional(),
segments=sub_segments_spec, ).func(check_full_segment_data).copy
).func(check_full_segment_data) subsegment_spec = segment_spec_base().update(
sub_segments_spec.optional().list(segment_spec) type=Spec().oneof(set((key for key in type_keys if key != 'segment_list'))).optional(),
del sub_segments_spec )
segment_spec = segment_spec_base().update(
type=Spec().oneof(type_keys).optional(),
segments=Spec().optional().list(subsegment_spec),
)
segments_spec = Spec().optional().list(segment_spec).copy segments_spec = Spec().optional().list(segment_spec).copy
segdict_spec = Spec( segdict_spec = Spec(
left=segments_spec().context_message('Error while loading segments from left side (key {key})'), left=segments_spec().context_message('Error while loading segments from left side (key {key})'),