(binding, decorators=None)
Apply `binding` to QtCompat

    Arguments:
        binding (str): Top level binding in _compatibility_members.
        decorators (dict, optional): Provides the ability to decorate the
            original Qt methods when needed by a binding. This can be used
            to change the returned value to a standard value. The key should
            be the classname, the value is a dict where the keys are the
            target method names, and the values are the decorator functions.
Apply `binding` to QtCompat
Apply binding to QtCompat
def _build_compatibility_members(binding, decorators=None):
    """Apply `binding` to QtCompat

    Arguments:
        binding (str): Top level binding in _compatibility_members.
        decorators (dict, optional): Provides the ability to decorate the
            original Qt methods when needed by a binding. This can be used
            to change the returned value to a standard value. The key should
            be the classname, the value is a dict where the keys are the
            target method names, and the values are the decorator functions.

    """

    decorators = decorators or dict()

    # Allow optional site-level customization of the compatibility members.
    # This method does not need to be implemented in QtSiteConfig.
    try:
        import QtSiteConfig
    except ImportError:
        pass
    else:
        if hasattr(QtSiteConfig, 'update_compatibility_decorators'):
            QtSiteConfig.update_compatibility_decorators(binding, decorators)

    _QtCompat = type("QtCompat", (object,), {})

    for classname, bindings in _compatibility_members[binding].items():
        attrs = {}
        for target, binding in bindings.items():
            namespaces = binding.split('.')
            try:
                src_object = getattr(Qt, "_" + namespaces[0])
            except AttributeError as e:
                _log("QtCompat: AttributeError: %s" % e)
                # Skip reassignment of non-existing members.
                # This can happen if a request was made to
                # rename a member that didn't exist, for example
                # if QtWidgets isn't available on the target platform.
                continue

            # Walk down any remaining namespace getting the object assuming
            # that if the first namespace exists the rest will exist.
            for namespace in namespaces[1:]:
                src_object = getattr(src_object, namespace)

            # decorate the Qt method if a decorator was provided.
            if target in decorators.get(classname, []):
                # staticmethod must be called on the decorated method to
                # prevent a TypeError being raised when the decorated method
                # is called.
                src_object = staticmethod(
                    decorators[classname][target](src_object))

            attrs[target] = src_object

        # Create the QtCompat class and install it into the namespace
        compat_class = type(classname, (_QtCompat,), attrs)
        setattr(Qt.QtCompat, classname, compat_class)
def _build_compatibility_members ( binding , decorators = None ) : decorators = decorators or dict ( ) # Allow optional site-level customization of the compatibility members. # This method does not need to be implemented in QtSiteConfig. try : import QtSiteConfig except ImportError : pass else : if hasattr ( QtSiteConfig , 'update_compatibility_decorators' ) : QtSiteConfig . update_compatibility_decorators ( binding , decorators ) _QtCompat = type ( "QtCompat" , ( object , ) , { } ) for classname , bindings in _compatibility_members [ binding ] . items ( ) : attrs = { } for target , binding in bindings . items ( ) : namespaces = binding . split ( '.' ) try : src_object = getattr ( Qt , "_" + namespaces [ 0 ] ) except AttributeError as e : _log ( "QtCompat: AttributeError: %s" % e ) # Skip reassignment of non-existing members. # This can happen if a request was made to # rename a member that didn't exist, for example # if QtWidgets isn't available on the target platform. continue # Walk down any remaining namespace getting the object assuming # that if the first namespace exists the rest will exist. for namespace in namespaces [ 1 : ] : src_object = getattr ( src_object , namespace ) # decorate the Qt method if a decorator was provided. if target in decorators . get ( classname , [ ] ) : # staticmethod must be called on the decorated method to # prevent a TypeError being raised when the decorated method # is called. src_object = staticmethod ( decorators [ classname ] [ target ] ( src_object ) ) attrs [ target ] = src_object # Create the QtCompat class and install it into the namespace compat_class = type ( classname , ( _QtCompat , ) , attrs ) setattr ( Qt . QtCompat , classname , compat_class )