From ac81cedb5bc6e5069fa809e6fc0b6dd242a9cd1c Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Sat, 7 Jul 2018 16:34:49 +0200 Subject: [PATCH] wip --- py3status/core.py | 38 +++++++++++++++++++++----------------- py3status/module.py | 6 +----- py3status/modules/wwan.py | 3 ++- tox.ini | 4 ++++ 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/py3status/core.py b/py3status/core.py index 193fd7d32f..d4dedccebf 100644 --- a/py3status/core.py +++ b/py3status/core.py @@ -904,18 +904,20 @@ def create_output_modules(self): for name in self.modules: if name not in output_modules: output_modules[name] = {} - output_modules[name]["position"] = positions.get(name, []) - output_modules[name]["module"] = self.modules[name] - output_modules[name]["type"] = "py3status" - output_modules[name]["color"] = self.mappings_color.get(name) + output_modules[name]['position'] = positions.get(name, []) + output_modules[name]['module'] = self.modules[name] + output_modules[name]['type'] = 'py3status' + output_modules[name]['color'] = self.mappings_color.get(name) + output_modules[name]['short_format'] = self.mappings_short_format.get(name) # i3status modules for name in i3modules: if name not in output_modules: output_modules[name] = {} - output_modules[name]["position"] = positions.get(name, []) - output_modules[name]["module"] = i3modules[name] - output_modules[name]["type"] = "i3status" - output_modules[name]["color"] = self.mappings_color.get(name) + output_modules[name]['position'] = positions.get(name, []) + output_modules[name]['module'] = i3modules[name] + output_modules[name]['type'] = 'i3status' + output_modules[name]['color'] = self.mappings_color.get(name) + output_modules[name]['short_format'] = self.mappings_short_format.get(name) self.output_modules = output_modules @@ -933,14 +935,14 @@ def create_mappings(self, config): color = None mappings[name] = color - max_size = self.get_config_attribute(name, 'max_size') - if hasattr(max_size, 'none_setting'): - max_size = None - mappings[name] = max_size + short_format = self.get_config_attribute(name, 'short_format') + if hasattr(short_format, 'none_setting'): + short_format = None + mappings[name] = short_format # Store mappings for later use. - self.mappings_max_size = mappings self.mappings_color = mappings + self.mappings_short_format = mappings def process_module_output(self, module): """ @@ -948,10 +950,12 @@ def process_module_output(self, module): Color processing occurs here. Shortened text 'short_text' processing occurs here. """ - outputs = module["module"].get_latest() - color = module["color"] - if color: - for output in outputs: + outputs = module['module'].get_latest() + color = module['color'] + short_format = module['short_format'] + + for output in outputs: + if color: # Color: substitute the config defined color if "color" not in output: output["color"] = color diff --git a/py3status/module.py b/py3status/module.py index 39e313bb47..8c42027352 100644 --- a/py3status/module.py +++ b/py3status/module.py @@ -650,8 +650,7 @@ def deprecation_log(item): if not hasattr(self.module_class, "py3"): setattr(self.module_class, "py3", Py3(self)) - # allow_urgent - # get the value form the config or use the module default if + # get the value from the config or use the module default if # supplied. fn = self._py3_wrapper.get_config_attribute param = fn(self.module_full_name, "allow_urgent") @@ -660,9 +659,6 @@ def deprecation_log(item): self.allow_urgent = param # max_size - # get the value form the config or use the module default if - # supplied. - fn = self._py3_wrapper.get_config_attribute param = fn(self.module_full_name, 'max_size') if hasattr(param, 'none_setting'): param = True diff --git a/py3status/modules/wwan.py b/py3status/modules/wwan.py index 022bfc3147..6802b87ae6 100644 --- a/py3status/modules/wwan.py +++ b/py3status/modules/wwan.py @@ -563,7 +563,8 @@ def wwan(self): response = { 'cached_until': self.py3.time_in(self.cache_timeout), - 'full_text': self.py3.safe_format(self.format, wwan_data) + 'full_text': self.py3.safe_format(self.format, wwan_data), + 'short_text': self.py3.safe_format(self.short_format, wwan_data) } if urgent: response['urgent'] = True diff --git a/tox.ini b/tox.ini index 279b3cf7af..e6435711f9 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,14 @@ skip_missing_interpreters = True [testenv] skip_install = True deps = + coverage pytest pytest-flake8 commands = pytest --flake8 + coverage erase + coverage run --omit=**/__init__.py --source=modules -m py.test + coverage report [testenv:py36] skip_install = True