40 lines
791 B
Python
40 lines
791 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
|
|
|
|
|
|
class UnitEnum(BaseEnum):
|
|
"""
|
|
Predefines units for selection
|
|
"""
|
|
mm = "mm"
|
|
dm = "dm"
|
|
cm = "cm"
|
|
m = "m"
|
|
km = "km"
|
|
|
|
qmm = "qmm"
|
|
qdm = "qdm"
|
|
qcm = "qcm"
|
|
qm = "qm"
|
|
qkm = "qkm"
|
|
ha = "ha"
|
|
|
|
st = "St." # pieces |