import six


def get_rotation(rotation):
    """
    Return the text angle as float. The returned
    angle is between 0 and 360 deg.

    *rotation* may be 'horizontal', 'vertical', or a numeric value in degrees.
    """
    try:
        angle = float(rotation)
    except (ValueError, TypeError):
        isString = isinstance(rotation, six.string_types)
        if ((isString and rotation == 'horizontal') or rotation is None):
            angle = 0.
        elif (isString and rotation == 'vertical'):
            angle = 90.
        else:
            raise ValueError("rotation is {0} expected either 'horizontal'"
                             " 'vertical', numeric value or"
                             "None".format(rotation))

    return angle % 360