mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Python cleanups
This commit is contained in:
parent
fb7c816124
commit
cefb1a2997
6 changed files with 27 additions and 14 deletions
|
@ -165,3 +165,5 @@ ignore_missing_imports = True
|
|||
ignore_missing_imports = True
|
||||
[mypy-pip_system_certs.*]
|
||||
ignore_missing_imports = True
|
||||
[mypy-anki_audio]
|
||||
ignore_missing_imports = True
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import atexit
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from typing import TYPE_CHECKING, Any, Union, cast
|
||||
|
@ -46,7 +46,6 @@ import builtins
|
|||
import cProfile
|
||||
import getpass
|
||||
import locale
|
||||
import os
|
||||
import tempfile
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
|
|
@ -14,9 +14,7 @@ import aqt.utils
|
|||
|
||||
class _MacOSHelper:
|
||||
def __init__(self) -> None:
|
||||
path = os.path.join(
|
||||
aqt.utils.aqt_data_folder(), "lib", "libankihelper.dylib"
|
||||
)
|
||||
path = os.path.join(aqt.utils.aqt_data_folder(), "lib", "libankihelper.dylib")
|
||||
|
||||
self._dll = CDLL(path)
|
||||
self._dll.system_is_dark.restype = c_bool
|
||||
|
|
|
@ -4,10 +4,14 @@
|
|||
"""Helpers for the packaged version of Anki."""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from anki.utils import is_mac
|
||||
|
||||
|
||||
# pylint: disable=unused-import
|
||||
def first_run_setup() -> None:
|
||||
"""Code run the first time after install/upgrade.
|
||||
|
||||
|
@ -24,26 +28,35 @@ def first_run_setup() -> None:
|
|||
|
||||
_dot()
|
||||
import anki.collection
|
||||
|
||||
_dot()
|
||||
import PyQt6.sip
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtCore
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtGui
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtNetwork
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtQuick
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtWebChannel
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtWebEngineCore
|
||||
|
||||
_dot()
|
||||
import PyQt6.QtWebEngineWidgets
|
||||
|
||||
_dot()
|
||||
import anki_audio
|
||||
import PyQt6.QtWidgets
|
||||
|
||||
import anki_audio
|
||||
audio_pkg_path = Path(anki_audio.__file__).parent
|
||||
|
||||
# Invoke mpv and lame
|
||||
|
@ -51,6 +64,6 @@ def first_run_setup() -> None:
|
|||
for cmd_name in ["mpv", "lame"]:
|
||||
_dot()
|
||||
cmd[0] = audio_pkg_path / cmd_name
|
||||
subprocess.run(cmd, check=True, capture_output=True)
|
||||
subprocess.run([str(cmd[0]), str(cmd[1])], check=True, capture_output=True)
|
||||
|
||||
print()
|
|
@ -283,6 +283,7 @@ def _packagedCmd(cmd: list[str]) -> tuple[Any, dict[str, str]]:
|
|||
if is_win or is_mac:
|
||||
try:
|
||||
import anki_audio
|
||||
|
||||
audio_pkg_path = Path(anki_audio.__file__).parent
|
||||
if is_win:
|
||||
packaged_path = audio_pkg_path / (cmd[0] + ".exe")
|
||||
|
|
Loading…
Reference in a new issue