21 lines
526 B
Python
21 lines
526 B
Python
|
"""
|
||
|
Author: Michel Peltriaux
|
||
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
||
|
Created on: 17.11.20
|
||
|
|
||
|
"""
|
||
|
|
||
|
from enum import Enum
|
||
|
|
||
|
|
||
|
class BaseEnum(Enum):
|
||
|
""" Provides basic functionality for Enums
|
||
|
|
||
|
"""
|
||
|
@classmethod
|
||
|
def as_choices(cls, drop_empty_choice: bool = False):
|
||
|
empty_choice = [] if drop_empty_choice else [(None, "---")]
|
||
|
choices = empty_choice + [(enum.value, enum.name) for enum in cls]
|
||
|
return choices
|