14 lines
380 B
Python
14 lines
380 B
Python
from enum import Enum
|
|
from typing import List
|
|
|
|
from image_prediction.formatter.formatter import Formatter
|
|
|
|
|
|
class EnumFormatter(Formatter):
|
|
@staticmethod
|
|
def __format(metadata: dict):
|
|
return {key.value if isinstance(key, Enum) else key: val for key, val in metadata.items()}
|
|
|
|
def format(self, metadata: List[dict]):
|
|
return map(self.__format, metadata)
|