Generate list of image types to create programmatically in the Web UI (#850)

* Generate list of image types to create programmatically based on rascsi capabilities, rather than a hard-coded list in the Web UI.

* Add explicit sorting of dicts for display in the Web UI, to avoid random order in certain environments.

* Remove redundant sorting line, and add code comments.

* Add helptext for the SCSI-1 image type
This commit is contained in:
Daniel Markstedt
2022-09-21 17:14:53 -07:00
committed by GitHub
parent e6ade9d510
commit e7775a72cc
3 changed files with 57 additions and 15 deletions

View File

@ -99,6 +99,39 @@ def get_device_name(device_type):
return device_type
def map_image_file_descriptions(file_suffixes):
"""
Takes a (list) of (str) file suffixes for images file types.
Returns a (dict) with file suffix and description pairs, both (str)
"""
supported_image_types = {}
for suffix in file_suffixes:
supported_image_types[suffix] = get_image_description(suffix)
return supported_image_types
# pylint: disable=too-many-return-statements
def get_image_description(file_suffix):
"""
Takes a three char file suffix (str) file_suffix.
Returns the help text description for said file suffix.
"""
if file_suffix == "hds":
return _("Hard Disk Image (Generic)")
if file_suffix == "hda":
return _("Hard Disk Image (Apple)")
if file_suffix == "hdn":
return _("Hard Disk Image (NEC)")
if file_suffix == "hd1":
return _("Hard Disk Image (SCSI-1)")
if file_suffix == "hdr":
return _("Removable Disk Image")
if file_suffix == "mos":
return _("Magneto-Optical Disk Image")
return file_suffix
def auth_active(group):
"""
Inspects if the group defined in (str) group exists on the system.