當前位置: 首頁>>代碼示例>>Python>>正文


Python ConfigDict.make_a_copy方法代碼示例

本文整理匯總了Python中cloudmesh_client.common.ConfigDict.ConfigDict.make_a_copy方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigDict.make_a_copy方法的具體用法?Python ConfigDict.make_a_copy怎麽用?Python ConfigDict.make_a_copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cloudmesh_client.common.ConfigDict.ConfigDict的用法示例。


在下文中一共展示了ConfigDict.make_a_copy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: do_register

# 需要導入模塊: from cloudmesh_client.common.ConfigDict import ConfigDict [as 別名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import make_a_copy [as 別名]

#.........這裏部分代碼省略.........
        elif arguments["backup"]:

            name = backup_name("~/.cloudmesh/cloudmesh.yaml")
            configfile = path_expand("~/.cloudmesh/cloudmesh.yaml")
            print (name)
            try:
                copy(configfile, name)
                Console.ok("Bakup copy created: {}. ok.".format(name))
            except:
                Console.error("Could not create a backup copy from {}".format(configfile))

            return ""

        elif arguments["new"]:

            import shutil
            import cloudmesh_client.etc

            config = ConfigDict("cloudmesh.yaml")
            data = dotdict({
                'dir': cloudmesh_client.etc.__file__,
                'filename': os.path.join(
                    os.path.dirname(cloudmesh_client.etc.__file__),
                    "cloudmesh.yaml"),
                'yamlfile': path_expand("~/.cloudmesh/cloudmesh.yaml"),
                'dryrun': arguments['--dryrun']
            })
            Console.ok(data.filename)
            force = arguments["--force"]
            if not force:
                force = yn_choice("Would you like create a new configuration file at {}".format(data.yamlfile))
            if force:
                if not data.dryrun:
                    config.make_a_copy(location=data.yamlfile)
                    shutil.copyfile(data.filename, data.yamlfile)
                print("copy ")
                print("From: ", data.filename)
                print("To:   ", data.yamlfile)

            # filename = _get_config_yaml_file(arguments)
            # if _exists(filename):
            #    Console.ok("File '{}' exists. ok.".format(filename))
            # else:
            #    Console.error("File {} does not exist".format(filename))
            return ""

        elif arguments["clean"]:

            filename = _get_config_yaml_file(arguments)
            force = arguments["--force"] or False
            if filename is not None:
                print(filename, force)
                if exists(filename):
                    print("Delete cloudmesh.yaml file:", filename)
                    if not force:
                        force = yn_choice("Would you like to delete the "
                                          "cloudmesh.yaml file")
                        print(force)
                    if force:
                        os.remove(filename)
                        Console.ok("Deleted the file " + filename + ". ok.")
                    else:
                        Console.ok("Please use Y to delete the file.")
                    pass
                else:
                    Console.error("File {} does not exist".format(filename))
開發者ID:cloudmesh,項目名稱:client,代碼行數:70,代碼來源:RegisterCommand.py


注:本文中的cloudmesh_client.common.ConfigDict.ConfigDict.make_a_copy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。