Python RNA getting the names of Vector axes. (eg "g" is color[1])
Guess you've tried this already, so forgive me if it doesn't suit your needs. It's also using hardcoding via a dictionary, the test runs based on the type of the property and the axis to test on:

import bpy
from mathutils import Vector, Color, Euler, Quaternion


classMap = {
    Vector:'xyz',
    Color:'rgb',
    Euler:'xyz',
    Quaternion:'wxyz'
}


def returnIndex(_driverProp, _axis):
    dictVal = classMap[type(_driverProp)]
    return(dictVal.index(_axis))

print (returnIndex(bpy.context.object.rotation_quaternion, 'y'))