(binding)
Apply misplaced members from `binding` to Qt.py

    Arguments:
        binding (dict): Misplaced members
Apply misplaced members from `binding` to Qt.py
Apply misplaced members from binding to Qt . py
def _reassign_misplaced_members(binding):
    """Apply misplaced members from `binding` to Qt.py

    Arguments:
        binding (dict): Misplaced members

    """

    for src, dst in _misplaced_members[binding].items():
        dst_value = None

        src_parts = src.split(".")
        src_module = src_parts[0]
        src_member = None
        if len(src_parts) > 1:
            src_member = src_parts[1:]

        if isinstance(dst, (list, tuple)):
            dst, dst_value = dst

        dst_parts = dst.split(".")
        dst_module = dst_parts[0]
        dst_member = None
        if len(dst_parts) > 1:
            dst_member = dst_parts[1]

        # Get the member we want to store in the namesapce.
        if not dst_value:
            try:
                _part = getattr(Qt, "_" + src_module)
                while src_member:
                    member = src_member.pop(0)
                    _part = getattr(_part, member)
                dst_value = _part
            except AttributeError:
                # If the member we want to store in the namespace does not
                # exist, there is no need to continue. 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.
                _log("Misplaced member has no source: {}".format(src))
                continue

        try:
            src_object = getattr(Qt, dst_module)
        except AttributeError:
            if dst_module not in _common_members:
                # Only create the Qt parent module if its listed in
                # _common_members. Without this check, if you remove QtCore
                # from _common_members, the default _misplaced_members will add
                # Qt.QtCore so it can add Signal, Slot, etc.
                msg = 'Not creating missing member module "{m}" for "{c}"'
                _log(msg.format(m=dst_module, c=dst_member))
                continue
            # If the dst is valid but the Qt parent module does not exist
            # then go ahead and create a new module to contain the member.
            setattr(Qt, dst_module, _new_module(dst_module))
            src_object = getattr(Qt, dst_module)
            # Enable direct import of the new module
            sys.modules[__name__ + "." + dst_module] = src_object

        if not dst_value:
            dst_value = getattr(Qt, "_" + src_module)
            if src_member:
                dst_value = getattr(dst_value, src_member)

        setattr(
            src_object,
            dst_member or dst_module,
            dst_value
        )
def _reassign_misplaced_members ( binding ) : for src , dst in _misplaced_members [ binding ] . items ( ) : dst_value = None src_parts = src . split ( "." ) src_module = src_parts [ 0 ] src_member = None if len ( src_parts ) > 1 : src_member = src_parts [ 1 : ] if isinstance ( dst , ( list , tuple ) ) : dst , dst_value = dst dst_parts = dst . split ( "." ) dst_module = dst_parts [ 0 ] dst_member = None if len ( dst_parts ) > 1 : dst_member = dst_parts [ 1 ] # Get the member we want to store in the namesapce. if not dst_value : try : _part = getattr ( Qt , "_" + src_module ) while src_member : member = src_member . pop ( 0 ) _part = getattr ( _part , member ) dst_value = _part except AttributeError : # If the member we want to store in the namespace does not # exist, there is no need to continue. 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. _log ( "Misplaced member has no source: {}" . format ( src ) ) continue try : src_object = getattr ( Qt , dst_module ) except AttributeError : if dst_module not in _common_members : # Only create the Qt parent module if its listed in # _common_members. Without this check, if you remove QtCore # from _common_members, the default _misplaced_members will add # Qt.QtCore so it can add Signal, Slot, etc. msg = 'Not creating missing member module "{m}" for "{c}"' _log ( msg . format ( m = dst_module , c = dst_member ) ) continue # If the dst is valid but the Qt parent module does not exist # then go ahead and create a new module to contain the member. setattr ( Qt , dst_module , _new_module ( dst_module ) ) src_object = getattr ( Qt , dst_module ) # Enable direct import of the new module sys . modules [ __name__ + "." + dst_module ] = src_object if not dst_value : dst_value = getattr ( Qt , "_" + src_module ) if src_member : dst_value = getattr ( dst_value , src_member ) setattr ( src_object , dst_member or dst_module , dst_value )