def get_name_from_proto(file_path): app_config = conf_pb2.AppConfig() read_proto_file(file_path, app_config) name = [] for f in app_config.filelist.file: name.append(f.name) return name
def convert(oldlist, newfilename, flat): appconfig = conf_pb2.AppConfig() file_list = appconfig.filelist #file_list = conf_pb2.FileList() file_list.root = "" with open(oldlist, 'r') as oldf: lines = oldf.readlines() for line in lines: sp = line.split(' ') relpath = sp[0] value = sp[1] file = file_list.file.add() file.name = relpath if flag == 'label': file.gold_label = float(value) if flag == 'score': file.gold_score = float(value) f = open(newfilename, "w") f.write(text_format.MessageToString(appconfig)) f.close()