view light8/Patch.py @ 54:3011c1028eb7

Cue math error fixed. Cue math error fixed. Bad cues in ConfigDummy fixed, not fixed in Config yet. Cue fader back in rsn. Oh yeah.
author dmcc
date Mon, 08 Jul 2002 15:50:00 +0000
parents 5e4fb4ac2d18
children 174b35926067
line wrap: on
line source

from types import TupleType

def get_dmx_channel(name):
    if name in patch:
        return patch[name]

    try:
        i = int(name)
        return i
    except ValueError:
        raise ValueError("Invalid channel name: %s" % name)

def get_channel_name(dmxnum):
    try:
        return reverse_patch[dmxnum]
    except KeyError:
        return str(dmxnum)

def reload_data(dummy):
    global patch, reverse_patch
    if dummy:
        import ConfigDummy as Config
    else:
        import Config

    reload(Config)
    loadedpatch = Config.patch
    patch = {}
    reverse_patch = {}
    for k, v in loadedpatch.items():
        if type(k) == TupleType:
            for name in k:
                patch[name] = v
            reverse_patch[v] = k[0]
        else:
            patch[k] = v
            reverse_patch[v] = k