def _plug_to_default(plug):
    'Find default value from plug, regardless of attribute type'
    if plug.isArray:
        raise TypeError('Array plugs are unsupported')
    if plug.isCompound:
        raise TypeError('Compound plugs are unsupported')
    attr = plug.attribute()
    type = attr.apiType()
    if (type == om.MFn.kTypedAttribute):
        return om.MFnTypedAttribute(attr).default
    elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute, om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
        return om.MFnUnitAttribute(attr).default
    elif (type == om.MFn.kNumericAttribute):
        return om.MFnNumericAttribute(attr).default
    elif (type == om.MFn.kEnumAttribute):
        return om.MFnEnumAttribute(attr).default
    else:
        raise TypeError(("Attribute type '%s' unsupported" % type))
Find default value from plug, regardless of attribute type
def _plug_to_default(plug):
    
    if plug.isArray:
        raise TypeError('Array plugs are unsupported')
    if plug.isCompound:
        raise TypeError('Compound plugs are unsupported')
    attr = plug.attribute()
    type = attr.apiType()
    if (type == om.MFn.kTypedAttribute):
        return om.MFnTypedAttribute(attr).default
    elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute, om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
        return om.MFnUnitAttribute(attr).default
    elif (type == om.MFn.kNumericAttribute):
        return om.MFnNumericAttribute(attr).default
    elif (type == om.MFn.kEnumAttribute):
        return om.MFnEnumAttribute(attr).default
    else:
        raise TypeError(("Attribute type '%s' unsupported" % type))