🐛 Solve sorted issues under Python 3.x
sorted does no longer support sorting None values under Python 3. This
patch introduces a utility function that ensures that None values are
replaced by a configurable default value ("" by default) and utilizes
it in places where sorted gets called with a custom sorting key that
can potentially consist of None values.
Closes #3300
This commit is contained in:
1 parent
09a4fb2515
commit
a889bec4d8
8 files changed
+26
-12
No files matched your search
@@ -9,6 +9,8 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
import requests
|
||||
import logging
|
||||
|
||||
from octoprint.util import sv
|
||||
|
||||
RELEASE_URL = "https://api.github.com/repos/{user}/{repo}/releases"
|
||||
|
||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.version_checks.github_release")
|
||||
@@ -69,7 +71,7 @@ def _filter_out_latest(releases,
|
||||
nothing = None, None, None
|
||||
|
||||
if sort_key is None:
|
||||
sort_key = lambda release: release.get("published_at", None)
|
||||
sort_key = lambda release: sv(release.get("published_at", None))
|
||||
|
||||
# filter out prereleases and drafts
|
||||
filter_function = lambda rel: not rel["prerelease"] and not rel["draft"]
|
||||
|
||||
Reference in new issue
Block a user