def _format_types_count(types_count, array_types_count=None):
""" Format types_count to a readable sting.
>>> format_types_count({'integer': 10, 'boolean': 5, 'null': 3, })
'integer : 10, boolean : 5, null : 3'
>>> format_types_count({'ARRAY': 10, 'null': 3, }, {'float': 4})
'ARRAY(float : 4) : 10, null : 3'
:param types_count: dict
:param array_types_count: dict, default None
:return types_count_string : str
"""
if types_count is None:
return str(None)
types_count = sorted(types_count.items(), key=lambda x: x[1], reverse=True)
type_count_list = list()
for type_name, count in types_count:
if type_name == 'ARRAY':
array_type_name = _SchemaPreProcessing._format_types_count(array_types_count)
type_count_list.append('ARRAY(' + array_type_name + ') : ' + str(count))
else:
type_count_list.append(str(type_name) + ' : ' + str(count))
types_count_string = ', '.join(type_count_list)
return types_count_string
评论列表
文章目录