F-Curves that are part of transforms come in sets of three or four. Internal code relies on their array_index
value to generate the axis name, or "W" in case of Quaternions. Other F-Curves also don't have a friendly name and internal code translates the name to display names.
The following code needs tidying up to put into an actual application, but consider it more or less pseudo-code. It's roughly how the internal code generates the names. It doesn't include the translation from internal name to pretty name.
This is just an example, run on an object that has been translated and rotated using a quaternion rotation, but not scaled. It has also been hidden in renders:
import bpy
object = bpy.context.object
action = object.animation_data.action
axis_name = [ "X", "Y", "Z" ]
quat_name = [ "W", "X", "Y", "Z" ]
for curve in action.fcurves:
if curve.data_path in ["location", "rotation_euler", "rotation_quaternion", "scale"]:
if "quaternion" in curve.data_path:
print(quat_name[curve.array_index], curve.data_path)
else:
print(axis_name[curve.array_index], curve.data_path)
else:
print(curve.data_path)
For the example I described it prints
X location
Y location
Z location
W rotation_quaternion
X rotation_quaternion
Y rotation_quaternion
Z rotation_quaternion
hide_render