load.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:operative-framework 作者: graniet 项目源码 文件源码
def export_data(export, export_file, export_status, title, argv):
    if len(export) > 0:
        if export_file == "":
        if argv == False:
            user_input = raw_input("operative (export file name ?) > ")
        else:
        user_input = argv
        if os.path.exists("export/"+user_input):
        export_file = "export/"+user_input
        elif os.path.exists(user_input):
        export_file = user_input
        else:
            print Fore.GREEN + "Writing " + user_input + " file" + Style.RESET_ALL
        export_file = "export/"+user_input
        export_data(export, export_file, export_status, title, argv)
    elif export_status == False:
        file_open = open(export_file,"a+")
        file_open.write(title)
        for line in export:
            aux = type(line)
            if str(aux) == "<type 'dict'>":
                for item in line.items():
                    file_open.write("- " + item[0] + ": " + item[1], )
                file_open.write("\n")
            else:
                file_open.write("- " + line +"\n")
        print Fore.GREEN + "File writed : " + export_file + Style.RESET_ALL
        file_open.close()
        export_status = True
    else:
        print Back.YELLOW + Fore.BLACK + "Module empty result" + Style.RESET_ALL
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号