annotate light8/Patch.py @ 17:43aa1ee8b3a9

some comments and garbage cleanup
author drewp
date Sun, 07 Jul 2002 06:43:40 +0000
parents f974a462133f
children 5e4fb4ac2d18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
1 from types import TupleType
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
2
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 def get_dmx_channel(name):
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 if name in patch:
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 return patch[name]
45b12307c695 Initial revision
drewp
parents:
diff changeset
6
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 i = int(name)
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 return i
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 except ValueError:
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
11 raise "Invalid channel name:", name
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
12
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 def get_channel_name(dmxnum):
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 try:
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 return reverse_patch[dmxnum]
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 except KeyError:
45b12307c695 Initial revision
drewp
parents:
diff changeset
17 return str(dmxnum)
45b12307c695 Initial revision
drewp
parents:
diff changeset
18
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
19 def reload_data(dummy):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 global patch, reverse_patch
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
21 if dummy:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
22 import ConfigDummy as Config
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
23 else:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
24 import Config
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
25
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
26 reload(Config)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
27 loadedpatch = Config.patch
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 patch = {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 reverse_patch = {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 for k, v in loadedpatch.items():
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
31 if type(k) == TupleType:
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 for name in k:
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 patch[name] = v
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 reverse_patch[v] = k[0]
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 patch[k] = v
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 reverse_patch[v] = k