I've moved this into the Developers' Forum as it's a general issue...
You can get info about a curve.
verts=curve.vertices returns the vertices, so if it's an arc etc then vf=verts.first and vl=verts.last are the end vertices.
You can also get the start and end edges with ef=curve.first_edge and el=curve.last_edges
You can get the edges that use any vertex with
edges=vertex.edges so do that for vf and vl in turn - the array of edges will include the curve's edge so fedges=vf.edges; fedges.delete(ef); fedgeyouwant=fedges[0] ditto for vl/ el
So you now have a way to find the two edges connected to ends of an curve.
This assumes you have checked it's a curve, it's not looped etc; and if there isn't a connected edge you get 'nil'. or if there are more than connected edge then only the first one found is returned...