replaced distutils version by the function get_version_from_string

This commit is contained in:
raphael60650 2021-09-03 22:53:08 +02:00
parent 9fed50fa93
commit 0edd631008
2 changed files with 5 additions and 6 deletions

View file

@ -1,4 +1,3 @@
from distutils.version import StrictVersion
from tkinter import filedialog, ttk, messagebox
from tkinter import *
import traceback
@ -9,7 +8,7 @@ import os
from source.Game import Game, RomAlreadyPatched, InvalidGamePath, InvalidFormat, in_thread, VERSION_FILE_URL
from source.Option import Option
from source.definition import sort_version_func
from source.definition import get_version_from_string
with open("./translation.json", encoding="utf-8") as f:
translation_dict = json.load(f)
@ -26,7 +25,7 @@ class Gui:
self.option.load_from_file("./option.json")
self.game = Game(gui=self)
self.game.ctconfig.load_ctconfig_file("./ct_config.json")
self.game.ctconfig.all_version.sort(key=sort_version_func)
self.game.ctconfig.all_version.sort(key=get_version_from_string)
latest_version: str = self.game.ctconfig.all_version[-1]
self.is_dev_version = False # Is this installer version a dev ?
@ -164,8 +163,8 @@ class Gui:
github_version_data = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
with open("./version", "rb") as f: local_version_data = json.load(f)
local_version = StrictVersion(f"{local_version_data['version']}.{local_version_data['subversion']}")
github_version = StrictVersion(f"{github_version_data['version']}.{github_version_data['subversion']}")
local_version = get_version_from_string(f"{local_version_data['version']}.{local_version_data['subversion']}")
github_version = get_version_from_string(f"{github_version_data['version']}.{github_version_data['subversion']}")
if github_version > local_version: # if github version is newer than local version
if messagebox.askyesno(

View file

@ -100,7 +100,7 @@ region_id_to_name = {
"E": "USA"
}
sort_version_func = lambda v: list(map(int, v.split('.')))
get_version_from_string = lambda v: list(map(int, v.split('.')))
def restart():
"""