I have converted polygon edges into polylines which I have also split at vertices. I am trying to rotate the polygon edges (segments) at angles which I have stored in a field in an attribute table.

The angles I have are for the polygon vertices. How do I proceed with rotating the segments -- preferably by scripting?

For instance, in the above image with a polygon, I need to move those 2 line segments until the angle between them are at right-angle and repeat same for all vertex/corners of the polygon.

EDIT: Providing additional context

Moving isn't the method. You have to pick the long side that will remain stationary, determine the short edge lengths and decide which you will use and derive its length. From the end points of the fixed long side and the desired edge length, you need to calculate the perpendicular offset points and replace the 'bad' long side points with these new values. You will then have a rectangle. You could do this iteratively, but that would be a wasted effort.

If these were constructed, make sure that the construct polygons with right angles is used.... 90 degrees all the time