def build_rgb_and_opacity(s):
    """
    Given a KML color string, return an equivalent
    RGB hex color string and an opacity float
    rounded to 2 decimal places.

    EXAMPLE::

        >>> build_rgb_and_opacity('ee001122')
        ('#221100', 0.93)

    """
    # Set defaults
    color = '000000'
    opacity = 1

    if s.startswith('#'):
        s = s[1:]
    if len(s) == 8:
        color = s[6:8] + s[4:6] + s[2:4]
        opacity = round(int(s[0:2], 16)/256, 2)
    elif len(s) == 6:
        color = s[4:6] + s[2:4] + s[0:2]
    elif len(s) == 3:
        color = s[::-1]

    return '#' + color, opacity
dataset/ETHPy150Open JamesMilnerUK/Loxo/conversiontools/kml/kml.py/build_rgb_and_opacity/original