Python script to convert connected SVG line segments into polylines