Commit 56b8cb11 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 637a49a8
......@@ -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
class AssetType(Enum):
"""All possible assets available on the BEAT platform"""
......@@ -70,6 +71,27 @@ class AssetType(Enum):
return path
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":
elif path == "toolchains":
return cls.TOOLCHAIN
raise RuntimeError("Unknown asset path {}".format(path))
class AssetModel(QStringListModel):
"""The asset model present a list of available asset from a given type"""
Supports Markdown
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