Question regarding exporting object rotation related to world axis

Hi!

Im very fresh to Python and coding in general, but some time ago I got an idea to try to utilize Blender as mapping tool for Arma 3. I have bashed together a script that exports selected objects classnames stored in custom property, their location and object local rotation and scale and writes them to .txt that can be imported to Arma 3 editor.

The problem lies with the rotations as Arma 3 Terrain Builder seems to use world axis rotations for its pitch(X) and roll(Z) (blender X and Y axis rotations) and object local up-direction axis rotation (yaw (Y) / blender Z) and I have no idea how to translate the local rotation to world rotation.

Might someone be able to give me advice on this?

-Goat