changeset 262:9bc5e908c361

Submasters have consistent repr(), new cmp and hash functions
author David McClosky <dmcc@bigasterisk.com>
date Thu, 16 Jun 2005 22:26:17 +0000
parents 473aa5b0610a
children 5da9139982c0
files light9/Submaster.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/light9/Submaster.py	Thu Jun 16 19:35:25 2005 +0000
+++ b/light9/Submaster.py	Thu Jun 16 22:26:17 2005 +0000
@@ -63,7 +63,9 @@
     def max(self, *othersubs):
         return sub_maxes(self, *othersubs)
     def __repr__(self):
-        levels = ' '.join(["%s:%.2f" % item for item in self.levels.items()])
+        items = self.levels.items()
+        items.sort()
+        levels = ' '.join(["%s:%.2f" % item for item in items])
         return "<'%s': [%s]>" % (self.name, levels)
     def get_dmx_list(self):
         leveldict = self.get_levels() # gets levels of sub contents
@@ -109,6 +111,10 @@
                                              amount))
 
         return xfaded_sub
+    def __cmp__(self, other):
+        return cmp(repr(self), repr(other))
+    def __hash__(self):
+        return hash(repr(self))
                                             
 def linear_fade(start, end, amount):
     """Fades between two floats by an amount.  amount is a float between