示例#1
0
    def save(self, notetype: NotetypeDict = None, **legacy_kwargs: bool) -> None:
        "Save changes made to provided note type."
        if not notetype:
            print_deprecation_warning(
                "col.models.save() should be passed the changed notetype"
            )
            return

        self.update(notetype, preserve_usn=False)
示例#2
0
def __getattr__(name):
    if name == "defaultDeck":
        print_deprecation_warning(
            "defaultDeck is deprecated; call decks.id() without it")
        return 0
    elif name == "defaultDynamicDeck":
        print_deprecation_warning(
            "defaultDynamicDeck is replaced with new_filtered()")
        return 1
    else:
        raise AttributeError(f"module {__name__} has no attribute {name}")
示例#3
0
    def timer(
        self,
        ms: int,
        func: Callable,
        repeat: bool,
        requiresCollection: bool = True,
        *,
        parent: QObject = None,
    ) -> QTimer:
        """Create and start a standard Anki timer. For an alternative see `single_shot()`.

        If the timer fires while a progress window is shown:
        - if it is a repeating timer, it will wait the same delay again
        - if it is non-repeating, it will try again in 100ms

        If requiresCollection is True, the timer will not fire if the
        collection has been unloaded. Setting it to False will allow the
        timer to fire even when there is no collection, but will still
        only fire when there is no current progress dialog.


        Issues and alternative
        ---
        The created timer will only be destroyed when `parent` is destroyed.
        This can cause memory leaks, because anything captured by `func` isn't freed either.
        If there is no QObject that will get destroyed reasonably soon, and you have to
        pass `mw`, you should call `deleteLater()` on the returned QTimer as soon as
        it's served its purpose, or use `single_shot()`.

        Also note that you may not be able to pass an adequate parent, if you want to
        make a callback after a widget closes. If you passed that widget, the timer
        would get destroyed before it could fire.
        """

        if parent is None:
            print_deprecation_warning(
                "to avoid memory leaks, pass an appropriate parent to progress.timer()"
                " or use progress.single_shot()")
            parent = self.mw

        qtimer = QTimer(parent)
        if not repeat:
            qtimer.setSingleShot(True)
        qconnect(qtimer.timeout,
                 self._get_handler(func, repeat, requiresCollection))
        qtimer.start(ms)
        return qtimer
示例#4
0
        def __getattr__(cls, provided_name):  # pylint: disable=no-self-argument
            # we know this is not an enum
            if provided_name == "__pyqtSignature__":
                raise AttributeError

            name = renamed_attrs.get(provided_name) or provided_name

            for enum_name in enums:
                enum = getattr(type, enum_name)
                try:
                    val = getattr(enum, name)
                except AttributeError:
                    continue

                print_deprecation_warning(
                    f"'{type_name}.{provided_name}' will stop working. Please use '{type_name}.{enum_name}.{name}' instead."
                )
                return val

            return getattr(type, name)
示例#5
0
 def _warn(self) -> None:
     print_deprecation_warning(
         "add-on should use methods on col.decks, not col.decks.decks dict")
示例#6
0
def qt_resource_system_call(*args, **kwargs):
    print_deprecation_warning(
        "The Qt resource system no longer works on PyQt6. "
        "Use QDir.addSearchPath() or mw.addonManager.setWebExports() instead.")
示例#7
0
def qt_exec_(object, *args, **kwargs):
    class_name = object.__class__.__name__
    print_deprecation_warning(
        f"'{class_name}.exec_()' is deprecated. Please use '{class_name}.exec()'"
    )
    return object.exec(*args, **kwargs)
示例#8
0
def qwebenginepage_view(page: QWebEnginePage) -> QWebEnginePage:
    print_deprecation_warning("'QWebEnginePage.view()' is deprecated. "
                              "Please use 'QWebEngineView.forPage(page)'")
    return QWebEngineView.forPage(page)