Commit 1102c54f authored by Jaden's avatar Jaden
Browse files

Use AssetType for finding valid prefix subfolders

Also simplifies AssetType enum,
makes it an IntEnum, and adds unique check
parent 3c0140c6
Pipeline #27855 passed with stage
in 6 minutes and 23 seconds
......@@ -25,7 +25,7 @@
import os
from enum import Enum
from enum import IntEnum, auto, unique
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSlot
......@@ -33,39 +33,37 @@ from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import QStringListModel
class AssetType(Enum):
@unique
class AssetType(IntEnum):
"""All possible assets available on the BEAT platform"""
(
Unknown,
Algorithm,
Database,
Dataformat,
Experiment,
Library,
Plotter,
PlotterParameters,
Toolchain,
) = range(9)
@classmethod
def path(cls, type_):
Unknown = 0
Algorithm = auto()
Database = auto()
Dataformat = auto()
Experiment = auto()
Library = auto()
Plotter = auto()
PlotterParameters = auto()
Toolchain = auto()
def path(self):
path = "unknown"
if type_ == cls.Algorithm:
if self == AssetType.Algorithm:
path = "algorithms"
elif type_ == cls.Database:
elif self == AssetType.Database:
path = "databases"
elif type_ == cls.Dataformat:
elif self == AssetType.Dataformat:
path = "dataformats"
elif type_ == cls.Experiment:
elif self == AssetType.Experiment:
path = "experiments"
elif type_ == cls.Library:
elif self == AssetType.Library:
path = "libraries"
elif type_ == cls.Plotter:
elif self == AssetType.Plotter:
path = "plotters"
elif type_ == cls.PlotterParameters:
elif self == AssetType.PlotterParameters:
path = "plotterparameters"
elif type_ == cls.Toolchain:
elif self == AssetType.Toolchain:
path = "toolchains"
return path
......@@ -92,9 +90,7 @@ class AssetModel(QStringListModel):
if not self.__prefix_path or self.__asset_type == AssetType.Unknown:
return
asset_folder = os.path.join(
self.__prefix_path, AssetType.path(self.__asset_type)
)
asset_folder = os.path.join(self.__prefix_path, self.__asset_type.path())
asset_users = os.scandir(asset_folder)
latest_assets_list = []
......
......@@ -45,6 +45,7 @@ from beat.cmdline.decorators import verbosity_option
from ..utils import setup_logger
from ..widgets.mainwindow import MainWindow
from ..backend.assetmodel import AssetType
EPILOG = """\b
Example:
......@@ -62,16 +63,7 @@ def editor(ctx):
# a list of folders to check in the prefix for object id matching
TYPE_FOLDERS = [
"dataformats",
"databases",
"libraries",
"algorithms",
"plotters",
"plotterparameters",
"toolchains",
"experiments",
]
TYPE_FOLDERS = [tp.path() for tp in AssetType if tp != AssetType.Unknown]
class BeatObjectIdParamType(click.ParamType):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment