import pymel.core as pm
import maya.cmds as cmds
# creates locators at selected controls parented under a master locator at the origin
# to assist in making sure pivot animations start/end properly
controls = cmds.ls(sl=True)
pivot_master = pm.spaceLocator(name='pivot_master_loc')
pm.xform(pivot_master, scale=(300, 100, 100))
for ctrl in controls:
# create a locator for the control
loc = pm.spaceLocator(name='{}_loc'.format(ctrl))
# get the worldspace coordinates and rotation order of the control
ctrl_translation = pm.xform(ctrl, q=True, ws=True, rp=True)
ctrl_rotation = pm.xform(ctrl, q=True, ws=True, ro=True)
ctrl_rotation_order = pm.xform(ctrl, q=True, roo=True)
# apply those coordinates to the locator
pm.xform(loc, roo=ctrl_rotation_order)
pm.xform(loc, scale=(80, 80, 80), translation=ctrl_translation, ro=ctrl_rotation)
pm.parent(loc, pivot_master)