本文整理汇总了Python中Shine.Configuration.ModelFile.ModelFile.save方法的典型用法代码示例。如果您正苦于以下问题:Python ModelFile.save方法的具体用法?Python ModelFile.save怎么用?Python ModelFile.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shine.Configuration.ModelFile.ModelFile
的用法示例。
在下文中一共展示了ModelFile.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSaveModelToFile
# 需要导入模块: from Shine.Configuration.ModelFile import ModelFile [as 别名]
# 或者: from Shine.Configuration.ModelFile.ModelFile import save [as 别名]
def testSaveModelToFile(self):
"""save a ModelFile to a file"""
testfile = makeTempFile("""foo: my test
bar: 3
foo: another
bar: 1
bar: 2""")
# Create a model
model = ModelFile()
model.add_element("foo", check="string", multiple=True)
model.add_element("bar", check="digit", multiple=True)
# Load a test file
model.load(testfile.name)
# Save it to a new file
filename = makeTempFilename()
model.save(filename, "# Some header")
# Reload the file in another model
model2 = model.emptycopy()
model2.load(filename)
os.unlink(filename)
# Compare the two files. They should have no difference
added, changed, removed = model.diff(model2)
self.assertTrue(len(changed) == len(added) == len(removed) == 0)