coordinates in pymxs

I need to replicate

in coordsys parent (

to the pymxs syntax but I dont know how :( any ideas?

I came with this but it not work

import pymxs

coords = pymxs.atlevel
rt = pymxs.runtime

def get_object_by_path(path):
converted_path = path.replace("|","/")
max_object = mxs.execute("$" + converted_path)
return max_object


getpos = p1.position
getrot = p1.rotation
getsca = p1.scale

p1.parent = p2

with coords("parent"):
p1.rotation = getrot
p1.position = getpos
p1.scale = getsca

Thanks for any help!