annotate light8/util.py @ 151:990a9474d0e7

early cue stuff. the CueList will supply the CueFader with the cues to early cue stuff. the CueList will supply the CueFader with the cues to work with, and will do crossfading sooner or later. the format of cues is still very open. cuelist1 is a bogus cuelist for testing.
author dmcc
date Sun, 06 Jul 2003 16:33:06 +0000
parents 71489bb71528
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 def maxes(dicts):
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 ({'a' : 5, 'b' : 9}, {'a' : 10, 'b' : 943})
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 newdict = {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 for d in dicts:
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 for k,v in d.items():
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 newdict[k] = max(v, newdict.get(k, 0))
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 return newdict
45b12307c695 Initial revision
drewp
parents:
diff changeset
10
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 def scaledict(d,scl):
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 # scales all values in dict and returns a new dict
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 return dict([(k,v*scl) for k,v in d.items()])
45b12307c695 Initial revision
drewp
parents:
diff changeset
14
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 # class Setting that scales, maxes
45
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
16
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
17 def subsetdict(d, dkeys, default=0):
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 45
diff changeset
18 """Subset of dictionary d: only the keys in dkeys. If you plan on omitting
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 45
diff changeset
19 keys, make sure you like the default."""
45
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
20 newd = {} # dirty variables!
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
21 for k in dkeys:
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
22 newd[k] = d.get(k, default)
62c47c3a90cb util.py: subsetdict added. see docs
dmcc
parents: 4
diff changeset
23 return newd