def from_string(dir_string):
    '''Returns the correct constant for a given string.

    @raises InvalidDirectionError

    '''
    dir_string = dir_string.upper()
    if dir_string == UP:
        return UP
    elif dir_string == DOWN:
        return DOWN
    elif dir_string == LEFT:
        return LEFT
    elif dir_string == RIGHT:
        return RIGHT
    else:
        raise InvalidDirectionError(dir_string)