[kupfer] objects: Adjust repr_key for RunnableLeaf and TextLeaf
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] objects: Adjust repr_key for RunnableLeaf and TextLeaf
- Date: Fri, 8 Jan 2010 15:47:51 +0000 (UTC)
commit 919565b34f64fd2fd474b24b6368f3f06ee513dc
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Fri Jan 8 04:55:14 2010 +0100
objects: Adjust repr_key for RunnableLeaf and TextLeaf
RunnableLeaves almost never need a representative key -- almost all
are "singletons" (all instances of a particular RunnableLeaf type are
identical).
TextLeaf uses the text hash as the repr_key -- it is a fixed length,
for any long text.
kupfer/objects.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index 1498f13..301a345 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -1043,6 +1043,8 @@ class RunnableLeaf (Leaf):
yield Do()
def run(self):
raise NotImplementedError
+ def repr_key(self):
+ return ""
class Do (Action):
"""Perform the action in a RunnableLeaf"""
@@ -1070,6 +1072,9 @@ class TextLeaf (Leaf, TextRepresentation):
def get_actions(self):
return ()
+ def repr_key(self):
+ return hash(self.object)
+
def get_description(self):
lines = [l for l in self.object.splitlines() if l.strip()]
desc = lines[0] if lines else self.object
@@ -1175,6 +1180,9 @@ class ComposedLeaf (RunnableLeaf):
yield Do()
yield TimedDo()
+ def repr_key(self):
+ return self
+
def run(self):
from kupfer import commandexec
ctx = commandexec.DefaultActionExecutionContext()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]