[core] do not scroll errors
to make errors easier to diagnose, do not scroll them, but instead fully show them. also, re-introduce the supplementary fields for the dwm bridge, kudos to @somospocos
This commit is contained in:
parent
4daae88a7c
commit
2ab575d190
5 changed files with 14 additions and 20 deletions
|
@ -19,7 +19,6 @@ def every(hours=0, minutes=0, seconds=0):
|
||||||
def scrollable(func):
|
def scrollable(func):
|
||||||
def wrapper(module, widget):
|
def wrapper(module, widget):
|
||||||
text = func(module, widget)
|
text = func(module, widget)
|
||||||
widget.set('_raw', text)
|
|
||||||
if not text:
|
if not text:
|
||||||
return text
|
return text
|
||||||
width = widget.get('theme.width', util.format.asint(module.parameter('width', 30)))
|
width = widget.get('theme.width', util.format.asint(module.parameter('width', 30)))
|
||||||
|
|
|
@ -101,11 +101,6 @@ class Error(Module):
|
||||||
self.__module = module
|
self.__module = module
|
||||||
self.__error = error
|
self.__error = error
|
||||||
|
|
||||||
self.set('scrolling.bounce', False)
|
|
||||||
self.set('scrolling.speed', 2)
|
|
||||||
self.set('width', 15)
|
|
||||||
|
|
||||||
@core.decorators.scrollable
|
|
||||||
def full_text(self, widget):
|
def full_text(self, widget):
|
||||||
return '{}: {}'.format(self.__module, self.__error)
|
return '{}: {}'.format(self.__module, self.__error)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,10 @@ def dump_json(obj):
|
||||||
|
|
||||||
def assign(src, dst, key, src_key=None, default=None):
|
def assign(src, dst, key, src_key=None, default=None):
|
||||||
if not src_key:
|
if not src_key:
|
||||||
src_key = key.replace('_', '-') # automagically replace - with _
|
if key.startswith('_'):
|
||||||
|
src_key = key
|
||||||
|
else:
|
||||||
|
src_key = key.replace('_', '-') # automagically replace _ with -
|
||||||
|
|
||||||
for k in src_key if isinstance(src_key, list) else [src_key]:
|
for k in src_key if isinstance(src_key, list) else [src_key]:
|
||||||
if k in src:
|
if k in src:
|
||||||
|
@ -80,7 +83,8 @@ class block(object):
|
||||||
|
|
||||||
for k in [
|
for k in [
|
||||||
'name', 'instance', 'separator_block_width', 'border', 'border_top',
|
'name', 'instance', 'separator_block_width', 'border', 'border_top',
|
||||||
'border_bottom', 'border_left', 'border_right', 'markup'
|
'border_bottom', 'border_left', 'border_right', 'markup',
|
||||||
|
'_raw', '_suffix', '_prefix'
|
||||||
]:
|
]:
|
||||||
assign(self.__attributes, result, k)
|
assign(self.__attributes, result, k)
|
||||||
|
|
||||||
|
@ -93,13 +97,12 @@ class block(object):
|
||||||
|
|
||||||
def __format(self, text):
|
def __format(self, text):
|
||||||
if text is None: return None
|
if text is None: return None
|
||||||
prefix = self.pangoize(self.__attributes.get('prefix'))
|
prefix = self.__pad(self.pangoize(self.__attributes.get('prefix')))
|
||||||
suffix = self.pangoize(self.__attributes.get('suffix'))
|
suffix = self.__pad(self.pangoize(self.__attributes.get('suffix')))
|
||||||
return '{}{}{}'.format(
|
self.set('_prefix', prefix)
|
||||||
self.__pad(prefix),
|
self.set('_suffix', suffix)
|
||||||
text,
|
self.set('_raw', text)
|
||||||
self.__pad(suffix)
|
return '{}{}{}'.format(prefix, text, suffix)
|
||||||
)
|
|
||||||
|
|
||||||
class i3(object):
|
class i3(object):
|
||||||
def __init__(self, theme=core.theme.Theme(), config=core.config.Config([])):
|
def __init__(self, theme=core.theme.Theme(), config=core.config.Config([])):
|
||||||
|
|
|
@ -26,7 +26,4 @@
|
||||||
- theme.exclude (battery)
|
- theme.exclude (battery)
|
||||||
- help output
|
- help output
|
||||||
- configuration files
|
- configuration files
|
||||||
- custom fields __ in output for dwm bridge
|
- use add_widget() instead of core.widget.Widget()
|
||||||
- default separators
|
|
||||||
- make a create_widget call in module
|
|
||||||
- do not scroll errors?
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class module(unittest.TestCase):
|
||||||
module = core.module.load(module_name=self.validModuleName, config=config)
|
module = core.module.load(module_name=self.validModuleName, config=config)
|
||||||
module.widget().full_text()
|
module.widget().full_text()
|
||||||
self.assertEqual('Error', module.__class__.__name__, 'an invalid module must be a core.module.Error')
|
self.assertEqual('Error', module.__class__.__name__, 'an invalid module must be a core.module.Error')
|
||||||
self.assertEqual(module.widget().get('_raw'), 'test: some-error')
|
self.assertEqual(module.widget().full_text(), 'test: some-error')
|
||||||
|
|
||||||
def test_loadvalid_module(self):
|
def test_loadvalid_module(self):
|
||||||
module = core.module.load(module_name=self.validModuleName)
|
module = core.module.load(module_name=self.validModuleName)
|
||||||
|
|
Loading…
Reference in a new issue