def get_proto_list_by_file(file_name):
    if file_name in cache_list:
        return cache_list[file_name]

    proto_files = ProtoFiles()
    proto_files.title = file_name

    file_path = files_path[files_name.index(file_name)]
    start_file = True
    content = []
    index_s = 0
    index_e = 0
    item = ProtoItem()
    for line in open(file_path, 'r', encoding='utf-8'):
        if line == '\n':
            continue
        #读取文件开头
        if start_file:
            if line.startswith('message Request'):
                start_file = False
                proto_files.description = ''.join(content[:index_e - 2])
                index_s = index_e - 2
        elif line.startswith('message Request'):
                item.description = content[index_s]
                item.cmdid = ''.join(list(filter(str.isnumeric, content[index_s + 2])))
                item.url = content[index_s + 1][7:]
                item.action = item.url.split('/')[-1]
                item.content = ''.join(content[index_s + 2 : index_e - 2])
                index_s = index_e - 2
                proto_files.add_proto(item)
                item = ProtoItem()

        content.append(line)
        index_e += 1

    item.description = content[index_s]
    item.cmdid = content[index_s + 2]
    item.url = content[index_s + 1][7:]
    item.content = ''.join(content[index_s + 2 : index_e - 2])
    item.action = item.url.split('/')[-1]
    proto_files.add_proto(item)

    cache_list[file_name] = proto_files.to_dict()
    return proto_files.to_dict()
def get_common(file_name='common'):
    """
    获取common文件中的类的信息
    :param file_name:
    :return:
    """
    if file_name in cache_common:
        return cache_common[file_name]

    proto_files = ProtoFiles()
    proto_files.title = file_name

    file_path = files_path[files_name.index(file_name)]
    index_s = 0
    index_e = 0
    content = []
    item = ProtoClass()
    start = True
    for line in open(file_path, 'r', encoding='utf-8'):
        if start:
            if line.startswith('message '):
                start = False
                proto_files.title = 'common'
                proto_files.description = ''.join(content[:index_e - 1])
                index_s = index_e
        elif line.startswith('message '):
                item.description = content[index_s - 1]
                item.content = ''.join(content[index_s : index_e - 1])
                item.action = content[index_s]
                index_s = index_e
                proto_files.add_proto(item)
                item = ProtoClass()

        content.append(line)
        index_e += 1

    item.description = content[index_s - 1]
    item.content = ''.join(content[index_s : index_e - 1])
    item.action = content[index_s]
    proto_files.add_proto(item)

    cache_common[file_name] = proto_files.to_dict()
    return proto_files.to_dict()