Browse Source

Sort script drop-down list alphabetically

Closes #1699
bugfix/handle_du
Safihre 4 years ago
parent
commit
f5f8aa985e
  1. 6
      sabnzbd/api.py

6
sabnzbd/api.py

@ -28,8 +28,8 @@ import time
import json import json
import cherrypy import cherrypy
import locale import locale
from threading import Thread from threading import Thread
from typing import List
try: try:
import win32api import win32api
@ -1854,7 +1854,7 @@ def calc_timeleft(bytesleft, bps):
return "0:00:00" return "0:00:00"
def list_scripts(default=False, none=True): def list_scripts(default: bool = False, none: bool = True) -> List[str]:
""" Return a list of script names, optionally with 'Default' added """ """ Return a list of script names, optionally with 'Default' added """
lst = [] lst = []
path = cfg.script_dir.get_path() path = cfg.script_dir.get_path()
@ -1871,6 +1871,8 @@ def list_scripts(default=False, none=True):
or (not sabnzbd.WIN32 and userxbit(script) and not os.path.basename(script).startswith(".")) or (not sabnzbd.WIN32 and userxbit(script) and not os.path.basename(script).startswith("."))
): ):
lst.append(os.path.basename(script)) lst.append(os.path.basename(script))
# Make sure capitalization is ignored to avoid strange results
lst = sorted(lst, key=str.casefold)
if none: if none:
lst.insert(0, "None") lst.insert(0, "None")
if default: if default:

Loading…
Cancel
Save