feature:first commit

This commit is contained in:
charlesxie
2022-01-28 16:09:30 +08:00
commit e5da67afbe
352 changed files with 45088 additions and 0 deletions

18
component/utils/basic.py Normal file
View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from collections import namedtuple
def tuple_choices(tupl):
"""从django-model的choices转换到namedtuple"""
return [(t, t) for t in tupl]
def dict_to_namedtuple(dic):
"""从dict转换到namedtuple"""
return namedtuple("AttrStore", list(dic.keys()))(**dic)
def choices_to_namedtuple(choices):
"""从django-model的choices转换到namedtuple"""
return dict_to_namedtuple(dict(choices))