mirror of
https://gitlab.com/Nanolx/qwad.git
synced 2024-11-22 02:29:18 +01:00
logical sorting of IOS in downloader
This commit is contained in:
parent
9b64027fd7
commit
ecc2a8e4c7
@ -2,6 +2,8 @@
|
||||
* add new IOS to downloader
|
||||
* show available versions of selected IOS in downloader
|
||||
* downloading channels is currently not possible
|
||||
* logical sorting of IOS in downloader (IOS4 is the first, not after IOS39)
|
||||
taken from: [http://code.activestate.com/recipes/135435/]
|
||||
|
||||
-- 0.3 --
|
||||
* Updated some porject's files which still referenced wii signer
|
||||
|
@ -26,7 +26,7 @@ class MWQwad(QMainWindow, Ui_Qwad):
|
||||
self.setupUi(self)
|
||||
self.defaultversion = self.trUtf8("""(Latest)""")
|
||||
self.VersionlineEdit.setText(self.defaultversion)
|
||||
for key in sorted(TitleIDs.TitleDict):
|
||||
for key in TitleIDs.sorted_copy(TitleIDs.TitleDict):
|
||||
self.comboBox.addItem(key)
|
||||
for ios in sorted(TitleIDs.IOSdict):
|
||||
self.IOSversion.addItem(ios)
|
||||
|
38
TitleIDs.py
38
TitleIDs.py
@ -5,6 +5,44 @@ module storing a titleid dictionary
|
||||
import binascii, re
|
||||
from PyQt4.QtCore import QT_TR_NOOP
|
||||
|
||||
|
||||
def sorted_copy(alist):
|
||||
# inspired by Alex Martelli
|
||||
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52234
|
||||
indices = map(_generate_index, alist)
|
||||
decorated = zip(indices, alist)
|
||||
decorated.sort()
|
||||
return [ item for index, item in decorated ]
|
||||
|
||||
def _generate_index(str):
|
||||
"""
|
||||
Splits a string into alpha and numeric elements, which
|
||||
is used as an index for sorting"
|
||||
"""
|
||||
#
|
||||
# the index is built progressively
|
||||
# using the _append function
|
||||
#
|
||||
index = []
|
||||
def _append(fragment, alist=index):
|
||||
if fragment.isdigit(): fragment = int(fragment)
|
||||
alist.append(fragment)
|
||||
|
||||
# initialize loop
|
||||
prev_isdigit = str[0].isdigit()
|
||||
current_fragment = ''
|
||||
# group a string into digit and non-digit parts
|
||||
for char in str:
|
||||
curr_isdigit = char.isdigit()
|
||||
if curr_isdigit == prev_isdigit:
|
||||
current_fragment += char
|
||||
else:
|
||||
_append(current_fragment)
|
||||
current_fragment = char
|
||||
prev_isdigit = curr_isdigit
|
||||
_append(current_fragment)
|
||||
return tuple(index)
|
||||
|
||||
TitleDict = {
|
||||
"BOOT2":"0000000100000001",
|
||||
"System Menu [JAP]":"0000000100000002",
|
||||
|
Loading…
Reference in New Issue
Block a user