Commit 2e168add authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[backend][assetmodel][AssetType] Added method to retrieve type from folder name

Also made the enum unique so that there's no way to have two
same values in it.
parent 0a43524a
......@@ -25,7 +25,7 @@
import os
from enum import Enum
from enum import Enum, unique
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSlot
......@@ -33,6 +33,7 @@ from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import QStringListModel
@unique
class AssetType(Enum):
"""All possible assets available on the BEAT platform"""
......@@ -70,6 +71,27 @@ class AssetType(Enum):
return path
@classmethod
def from_path(cls, path):
if path == "algorithms":
return cls.ALGORITHM
elif path == "databases":
return cls.DATABASE
elif path == "dataformats":
return cls.DATAFORMAT
elif path == "experiments":
return cls.EXPERIMENT
elif path == "libraries":
return cls.LIBRARY
elif path == "plotters":
return cls.PLOTTER
elif path == "plotterparameters":
return cls.PLOTTERPARAMETERS
elif path == "toolchains":
return cls.TOOLCHAIN
else:
raise RuntimeError("Unknown asset path {}".format(path))
class AssetModel(QStringListModel):
"""The asset model present a list of available asset from a given type"""
......
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