def findStyleName(element, style):

    oldStyle = DOM.getAttribute(element, "className")
    if oldStyle is None:
        return -1
    idx = oldStyle.find(style)

    # Calculate matching index
    lastPos = len(oldStyle)
    while idx != -1:
        if idx == 0 or (oldStyle[idx - 1] == " "):
            last = idx + len(style)
            if (last == lastPos) or ((last < lastPos) and \
                                     (oldStyle[last] == " ")):
                break
        idx = oldStyle.find(style, idx + 1)

    return idx
dataset/ETHPy150Open pyjs/pyjs/pyjswidgets/pyjamas/ui/UIObject.py/findStyleName/original