From fca364554e9fab67557d3ddda56d5440c65ac60e Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 8 Feb 2020 13:45:52 +0100 Subject: [PATCH] [core/output] Add id of widget and module to output In the process of that, fix a bug in how the parent class constructors were invoked. --- core/output.py | 4 +++- core/widget.py | 4 +++- tests/util/test_store.py | 5 +---- util/store.py | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/output.py b/core/output.py index 4141e75..c02afdd 100644 --- a/core/output.py +++ b/core/output.py @@ -38,7 +38,9 @@ class i3(object): for module in self._modules: for widget in module.widgets(): status.append({ - 'full_text': widget.full_text() + 'full_text': widget.full_text(), + 'instance': widget.id(), + 'name': module.id(), }) return { 'data': status, diff --git a/core/widget.py b/core/widget.py index 36b0c32..650fd4c 100644 --- a/core/widget.py +++ b/core/widget.py @@ -1,7 +1,9 @@ +import core.input import util.store -class Widget(util.store.Store): +class Widget(util.store.Store, core.input.Object): def __init__(self, full_text): + super(Widget, self).__init__() self._full_text = full_text def full_text(self, value=None): diff --git a/tests/util/test_store.py b/tests/util/test_store.py index 70225d0..71cbffa 100644 --- a/tests/util/test_store.py +++ b/tests/util/test_store.py @@ -2,7 +2,7 @@ import unittest import util.store -class config(unittest.TestCase): +class store(unittest.TestCase): def setUp(self): self.store = util.store.Store() @@ -12,9 +12,6 @@ class config(unittest.TestCase): self.someValue = "someRandomValue" self.someOtherValue = "anotherRandomValue" - def tearDown(self): - pass - def test_get_of_unset_key(self): self.assertEqual(None, self.store.get(self.unusedKey), 'default value expected to be None') self.assertEqual(self.someValue, self.store.get(self.unusedKey, self.someValue), 'wrong user-provided default value returned') diff --git a/util/store.py b/util/store.py index 81c8452..79057af 100644 --- a/util/store.py +++ b/util/store.py @@ -8,6 +8,7 @@ this module class Store(object): """Interface for storing and retrieving simple values""" def __init__(self): + super(Store, self).__init__() self._data = {} def set(self, key, value):