2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-16 01:36:29 +00:00

PEP fixes (not all yet)

This commit is contained in:
Oliver
2018-04-18 00:03:42 +10:00
parent 3f33a921ae
commit 192f823b1a
11 changed files with 25 additions and 37 deletions

View File

@@ -1,18 +0,0 @@
import inspect
from enum import Enum
class ChoiceEnum(Enum):
""" Helper class to provide enumerated choice values for integer fields
"""
# http://blog.richard.do/index.php/2014/02/how-to-use-enums-for-django-field-choices/
@classmethod
def choices(cls):
# get all members of the class
members = inspect.getmembers(cls, lambda m: not(inspect.isroutine(m)))
# filter down to just properties
props = [m for m in members if not(m[0][:2] == '__')]
# format into django choice tuple
choices = tuple([(str(p[1].value), p[0]) for p in props])
return choices