Conversion of Z-matrix to Cartesian coordinates
I will try to answer the question in bold from a mathematical perspective.

Basically, the first two lines in get_local_axes are to build the vectors $\vec r_{12}$ and $\vec r_{23}$. The next line builds the cross product $$\frac{\vec r_{23}\times\vec r_{12}}{|\vec r_{23}\times\vec r_{12}|},$$

The next vector is
$$\frac{\vec r_{12}\times(\vec r_{23}\times\vec r_{12})}{|\vec r_{12}\times(\vec r_{23}\times\vec r_{12})|},$$

This is a vector perpendicular to $\vec r_{12}$, and lies in the plane where $\vec r_{12}$ and $\vec r_{23}$ lie.

The next lines are defining the three axes of the system. $\vec e_z$ is just $\vec r_{12}$ normalized, $\vec e_y$ is chosen so that $yz$ is the plane where the three points (atoms) locate. and $\vec e_x$ is chosen so that $(\vec e_x, \vec e_y, \vec e_z)$ forms a orthonormal set and are the versors of a right-handed coordinate system. This system is the local axis system.

So this is the meaning of "getting local axis system from 3 coordinates".