Reformat
This commit is contained in:
parent
d9e3dec0c2
commit
cdf9176258
@ -16,6 +16,7 @@ class CommandEndpoint:
|
|||||||
:param modules: dict-like object with item access semantics via .get()
|
:param modules: dict-like object with item access semantics via .get()
|
||||||
:param io_handler_factory: function creating a file-like object returning a JSON generator on .read()
|
:param io_handler_factory: function creating a file-like object returning a JSON generator on .read()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, modules, io_handler_factory):
|
def __init__(self, modules, io_handler_factory):
|
||||||
self.modules = modules
|
self.modules = modules
|
||||||
self.io_handler_factory = io_handler_factory
|
self.io_handler_factory = io_handler_factory
|
||||||
@ -57,25 +58,25 @@ class Status:
|
|||||||
"""Register a new module."""
|
"""Register a new module."""
|
||||||
from i3pystatus.text import Text
|
from i3pystatus.text import Text
|
||||||
|
|
||||||
if module:
|
if not module:
|
||||||
try:
|
return
|
||||||
return self.modules.append(module, *args, **kwargs)
|
|
||||||
except ImportError as import_error:
|
try:
|
||||||
if import_error.name and not import_error.path and isinstance(module, str):
|
return self.modules.append(module, *args, **kwargs)
|
||||||
# This is a package/module not found exception raised by importing a module on-the-fly
|
except ImportError as import_error:
|
||||||
return self.modules.append(Text(
|
if import_error.name and not import_error.path and isinstance(module, str):
|
||||||
color="#FF0000",
|
# This is a package/module not found exception raised by importing a module on-the-fly
|
||||||
text="{i3py_mod}: Missing Python module '{missing_module}'".format(
|
|
||||||
i3py_mod=module,
|
|
||||||
missing_module=import_error.name)))
|
|
||||||
else:
|
|
||||||
raise import_error
|
|
||||||
except ConfigError as configuration_error:
|
|
||||||
return self.modules.append(Text(
|
return self.modules.append(Text(
|
||||||
color="#FF0000",
|
color="#FF0000",
|
||||||
text=configuration_error.message))
|
text="{i3py_mod}: Missing Python module '{missing_module}'".format(
|
||||||
else:
|
i3py_mod=module,
|
||||||
return None
|
missing_module=import_error.name)))
|
||||||
|
else:
|
||||||
|
raise import_error
|
||||||
|
except ConfigError as configuration_error:
|
||||||
|
return self.modules.append(Text(
|
||||||
|
color="#FF0000",
|
||||||
|
text=configuration_error.message))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.command_endpoint.start()
|
self.command_endpoint.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user