Using maya.cmds you'd probably want to execute the MEL commands that do the same actions Andres detailed. I'm not sure how to do that but if you turn on "Echo All Commands" in the Script Editor and do some digging in the MEL scripts that ship with Maya, you might be able to figure it out.
Using PyMel, or the C++ or Python API, I think you could do it faster than the script you linked by using the isRightHandedTangent function of PyMel's Mesh or the API's MFnMesh class. (You can pass UV ids to that function.) You'd still have to iterate through all UV IDs but you let Maya do the vector math for you. You would then probably select the left-handed UVs for the user to flip. Flipping them in script would be more complex because you'd have to account for cases where a UV shell folds on itself.
Hi Michael, yes I am able to use the solution given by Andres and convert them using maya.cmds.polyMultiLayoutUV.
By the way, how are you able to tell that the script I have linked is using the isRightHandedTangent function (I have hardly used PyMel, mostly I am using maya.cmds)?
I have also managed to find another script that uses both PyMel and Maya Api altogether. Tried running it (though there are some errors), I think it run similarly to the script I have linked previously but it is still slow, nowhere fast as the solution provided by Andres.
To my knowledge, I had thought that using of maya api will makes the process faster? Wondering if the cause of slowness could be due to PyMel - read that PyMel is more in ease of use over execution speed