mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 08:45:15 +02:00
Improve lint number (interval and priority) checks
This commit is contained in:
parent
88865b1145
commit
296107d68e
@ -177,12 +177,14 @@ class Spec(object):
|
|||||||
def cmp(self, comparison, cint, msg_func=None):
|
def cmp(self, comparison, cint, msg_func=None):
|
||||||
if type(cint) is str:
|
if type(cint) is str:
|
||||||
self.type(unicode)
|
self.type(unicode)
|
||||||
|
elif type(cint) is float:
|
||||||
|
self.type(int, float)
|
||||||
else:
|
else:
|
||||||
self.type(type(cint))
|
self.type(type(cint))
|
||||||
cmp_func = self.cmp_funcs[comparison]
|
cmp_func = self.cmp_funcs[comparison]
|
||||||
msg_func = msg_func or (lambda value: '{0} is not {1} {2}'.format(value, self.cmp_msgs[comparison], cint))
|
msg_func = msg_func or (lambda value: '{0} is not {1} {2}'.format(value, self.cmp_msgs[comparison], cint))
|
||||||
self.checks.append(('check_func',
|
self.checks.append(('check_func',
|
||||||
(lambda value, *args: (True, True, not cmp_func(value, cint))),
|
(lambda value, *args: (True, True, not cmp_func(value.value, cint))),
|
||||||
msg_func))
|
msg_func))
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -416,7 +418,7 @@ main_spec = (Spec(
|
|||||||
log_level=Spec().re('^[A-Z]+$').func(lambda value, *args: (True, True, not hasattr(logging, value)),
|
log_level=Spec().re('^[A-Z]+$').func(lambda value, *args: (True, True, not hasattr(logging, value)),
|
||||||
lambda value: 'unknown debugging level {0}'.format(value)).optional(),
|
lambda value: 'unknown debugging level {0}'.format(value)).optional(),
|
||||||
log_format=Spec().type(str).optional(),
|
log_format=Spec().type(str).optional(),
|
||||||
interval=Spec().type(int, float, type(None)).optional(),
|
interval=Spec().either(Spec().cmp('gt', 0.0), Spec().type(type(None))).optional(),
|
||||||
).context_message('Error while loading common configuration (key {key})'),
|
).context_message('Error while loading common configuration (key {key})'),
|
||||||
ext=Spec(
|
ext=Spec(
|
||||||
vim=Spec(
|
vim=Spec(
|
||||||
@ -797,7 +799,7 @@ def check_segment_data_key(key, data, context, echoerr):
|
|||||||
|
|
||||||
# FIXME More checks, limit existing to ThreadedSegment instances only
|
# FIXME More checks, limit existing to ThreadedSegment instances only
|
||||||
args_spec = Spec(
|
args_spec = Spec(
|
||||||
interval=Spec().type(int, float).optional(),
|
interval=Spec().cmp('gt', 0.0).optional(),
|
||||||
update_first=Spec().type(bool).optional(),
|
update_first=Spec().type(bool).optional(),
|
||||||
shutdown_event=Spec().error('Shutdown event must be set by powerline').optional(),
|
shutdown_event=Spec().error('Shutdown event must be set by powerline').optional(),
|
||||||
pl=Spec().error('pl object must be set by powerline').optional(),
|
pl=Spec().error('pl object must be set by powerline').optional(),
|
||||||
@ -815,7 +817,7 @@ segments_spec = Spec().optional().list(
|
|||||||
draw_soft_divider=Spec().type(bool).optional(),
|
draw_soft_divider=Spec().type(bool).optional(),
|
||||||
draw_inner_divider=Spec().type(bool).optional(),
|
draw_inner_divider=Spec().type(bool).optional(),
|
||||||
module=segment_module_spec(),
|
module=segment_module_spec(),
|
||||||
priority=Spec().cmp('ge', -1).optional(),
|
priority=Spec().either(Spec().cmp('eq', -1), Spec().cmp('ge', 0.0)).optional(),
|
||||||
after=Spec().type(unicode).optional(),
|
after=Spec().type(unicode).optional(),
|
||||||
before=Spec().type(unicode).optional(),
|
before=Spec().type(unicode).optional(),
|
||||||
width=Spec().either(Spec().unsigned(), Spec().cmp('eq', 'auto')).optional(),
|
width=Spec().either(Spec().unsigned(), Spec().cmp('eq', 'auto')).optional(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user