Accessing bone name of a driver in pose mode from python

I wanted to write a python script to copy the drivers of one object to another but am having some trouble with it. The drivers are set to type “pose mode”. In the IpoCurve module, I can use driverObject to get the armature that the bone is from, and I can get the axis of rotation/location/resizing with driverChannel. However, I still need a way to get the name of the bone of the armature given by driverObject that the driver uses.

I found this page on the web which includes the following code:

            if ipo_curve.driver:
                new_curve.driver = ipo_curve.driver
                if ipo_curve.<b>driverObject</b>:
                    new_curve.<b>driverObject</b> = ipo_curve.<b>driverObject</b>
                new_curve.driverChannel = ipo_curve.driverChannel
                new_curve.driverExpression = ipo_curve.driverExpression

Here, the driverObject, driverChannel, and driverExpression are copied to the new curve, but I don’t see where the bone would get copied in cases where the driver is “pose” type instead of “object” type.

I also find some of the documentation on this page confusing. It says, “Status of the driver. 1= on, 0= object, 2= python expression,” but when I called IpoCurve.driver, I got 0 when there was no driver, 1 when the driver was either of type object or of type pose, and 2 when it was python driven.

To make a copy with all the driver data, I convert all drivers in the source object to pydrivers. Using pydrivers you can pass the armature and the bone name to the copy using the driverExpression property.