summaryrefslogtreecommitdiff
path: root/python/astal/binding.py
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-07-15 22:09:58 +0200
committerAylur <[email protected]>2024-07-15 22:09:58 +0200
commite5251d23f158c7cc092121c3a7cc0438a73746ec (patch)
treedbd972adfb768e5600ca15f779b4cffc666a442f /python/astal/binding.py
parentbe163b310398ad7f454d3ece574a476abfa216e9 (diff)
remove python and node
I have no desire to work on the python version The node version has the issue of promises not working which makes it unusable but gjs works just as good if not better. Might look back into node later
Diffstat (limited to 'python/astal/binding.py')
-rw-r--r--python/astal/binding.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/python/astal/binding.py b/python/astal/binding.py
deleted file mode 100644
index 0fe1b6c..0000000
--- a/python/astal/binding.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import re
-
-
-def kebabify(string):
- return re.sub(r"([a-z])([A-Z])", r"\1-\2", string).replace("_", "-").lower()
-
-
-class Binding:
- def __init__(self, emitter, prop=None):
- self.emitter = emitter
- self.prop = kebabify(prop) if prop else None
- self.transform_fn = lambda v: v
-
- def __str__(self):
- return f"Binding<{self.emitter}{', ' + self.prop if self.prop else ''}>"
-
- def as_(self, fn):
- bind = Binding(self.emitter, self.prop)
- bind.transform_fn = lambda v: fn(self.transform_fn(v))
- return bind
-
- def get(self):
- if hasattr(self.emitter, "get") and callable(self.emitter.get):
- return self.transform_fn(self.emitter.get())
-
- return self.transform_fn(self.emitter[f"get_{self.prop}"]())
-
- def subscribe(self, callback):
- if hasattr(self.emitter, "subscribe") and callable(self.emitter.subscribe):
- return self.emitter.subscribe(lambda _: callback(self.get()))
-
- i = self.emitter.connect(f"notify::{self.prop}", lambda: callback(self.get()))
- return lambda: self.emitter.disconnect(i)