2022-03-31 12:52:15 +02:00

17 lines
435 B
Python

from funcy import walk_keys, walk
from image_prediction.formatter.formatter import Formatter
class Snake2CamelCaseKeyFormatter(Formatter):
@staticmethod
def __format(key: str):
if isinstance(key, str):
head, *tail = key.split("_")
return head + "".join(map(lambda s: s.title(), tail))
else:
return key
def format(self, data):
return walk(self.__format, data)