Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Nov 15, 2024
1 parent 01ac20e commit f54af2a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions napari_plugin_manager/qt_check_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
from urllib.error import HTTPError, URLError
from urllib.request import urlopen

import packaging.version
import packaging
from napari.utils.notifications import show_warning
import packaging.version
from napari import __version__
from napari._qt.qthreading import create_worker
from napari._qt.qt_resources import get_current_stylesheet
from napari.utils.notifications import show_warning
from qtpy.QtCore import QObject
from qtpy.QtWidgets import QMessageBox
from superqt import ensure_main_thread
from napari import __version__


IGNORE_DAYS = 21
IGNORE_FILE = "ignore.txt"
Expand All @@ -43,7 +41,7 @@ def github_tags():

@lru_cache
def conda_forge_releases():
url = f'https://api.anaconda.org/package/conda-forge/napari/'
url = 'https://api.anaconda.org/package/conda-forge/napari/'
with urlopen(url) as r:
data = json.load(r)
versions = data.get('versions', [])
Expand Down Expand Up @@ -84,10 +82,13 @@ def __init__(self, parent=None):
self._base_folder = sys.prefix

def check(self):

if os.path.exists(os.path.join(self._base_folder, IGNORE_FILE)):
with (
open(os.path.join(self._base_folder, IGNORE_FILE), encoding="utf-8") as f_p,
open(
os.path.join(self._base_folder, IGNORE_FILE),
encoding="utf-8",
) as f_p,
suppress(ValueError),
):
old_date = date.fromisoformat(f_p.read())
Expand All @@ -110,12 +111,17 @@ def show_version_info(self, latest_version):
"New release",
f"You use outdated version of napari. "
f"Your version is {my_version} and current is {remote_version}.",
QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore,
QMessageBox.StandardButton.Ok
| QMessageBox.StandardButton.Ignore,
)

if message.exec_() == QMessageBox.StandardButton.Ignore:
os.makedirs(self._base_folder, exist_ok=True)
with open(os.path.join(self._base_folder, IGNORE_FILE), "w", encoding="utf-8") as f_p:
with open(
os.path.join(self._base_folder, IGNORE_FILE),
"w",
encoding="utf-8",
) as f_p:
f_p.write(date.today().isoformat())


Expand Down

0 comments on commit f54af2a

Please sign in to comment.