本文整理汇总了Python中eppy.modeleditor.IDF.save方法的典型用法代码示例。如果您正苦于以下问题:Python IDF.save方法的具体用法?Python IDF.save怎么用?Python IDF.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eppy.modeleditor.IDF
的用法示例。
在下文中一共展示了IDF.save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_copy
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save_copy(self):
"""Test savecopy with a new filename.
IDF.savecopy(fname) doesn't change the filename. The next save should
save with the original name.
Fails if on a following save, the copy is changed.
"""
idf = IDF(self.startfile)
idf.savecopy(self.copyfile)
setversion(idf, '7.5')
idf.save()
idf2 = IDF(self.copyfile)
result = getversion(idf2)
expected = '7.3' # unchanged since version was changed after savecopy
assert result == expected
idf3 = IDF(self.startfile)
result = getversion(idf3)
expected = '7.5' # should be changed in the original file
assert result == expected
示例2: test_save
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save():
"""
Test the IDF.save() function using a filehandle to avoid external effects.
"""
file_text = "Material,TestMaterial, !- Name"
idf = IDF(StringIO(file_text))
# test save with just a filehandle
file_handle = StringIO()
idf.save(file_handle)
expected = "TestMaterial"
file_handle.seek(0)
result = file_handle.read()
# minimal test that TestMaterial is being written to the file handle
assert expected in result
示例3: test_save
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save(self):
"""Test save with a changed version number.
Fails if the version number has not been changed.
"""
idf = IDF(self.startfile)
setversion(idf, '7.4')
idf.save()
idf2 = IDF(self.startfile)
assert idf is not idf2 # be sure we don't just have an in-memory copy
result = getversion(idf2)
expected = '7.4'
assert result == expected
示例4: test_lineendings
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_lineendings(self):
"""Test lineendings are set correctly on each platform.
"""
idf = IDF(self.startfile)
idf.save(lineendings='windows')
with open(self.startfile, 'rb') as sf:
txt = sf.read()
print(txt.count(b'\r\n'))
lines = txt.splitlines()
numlines = len(lines)
assert numlines == txt.count(b'\r\n') + 1 # no CR on last line
idf.save(lineendings='unix')
with open(self.origfile, 'rb') as of:
txt = of.read()
lines = txt.splitlines()
numlines = len(lines)
assert numlines == txt.count(b'\n') + 1 # no CR on last line
示例5: test_save_as
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save_as(self):
"""Test saveas with a changed filename.
IDF.saveas(fname) changes the filename. The next save should save with
new name.
Fails if the filename isn't changed on the file with the new name.
"""
idf = IDF(self.startfile)
idf.saveas(self.saveasfile) # sets the new filename
setversion(idf, '7.4')
idf.save() # should also save with the new filename
idf2 = IDF(self.saveasfile)
result = getversion(idf2)
expected = '7.4'
assert result == expected
示例6: test_save_with_lineendings_and_encodings
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save_with_lineendings_and_encodings(self):
"""
Test the IDF.save() function with combinations of encodings and line
endings.
"""
idf = IDF(self.startfile)
lineendings = ('windows', 'unix', 'default')
encodings = ('ascii', 'latin-1', 'UTF-8')
for le, enc in product(lineendings, encodings):
idf.save(lineendings=le, encoding=enc)
with open(self.startfile, 'rb') as sf:
result = sf.read()
if le == 'windows':
assert b'\r\n' in result
elif le == 'unix':
assert b'\r\n' not in result
elif le == 'default':
assert os.linesep.encode(enc) in result
示例7: test_save_with_lineendings_and_encodings
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
def test_save_with_lineendings_and_encodings():
"""
Test the IDF.save() function with combinations of encodings and line
endings.
"""
file_text = "Material,TestMaterial, !- Name"
idf = IDF(StringIO(file_text))
lineendings = ('windows', 'unix', 'default')
encodings = ('ascii', 'latin-1', 'UTF-8')
for le, enc in product(lineendings, encodings):
file_handle = StringIO()
idf.save(file_handle, encoding=enc, lineendings=le)
file_handle.seek(0)
result = file_handle.read().encode(enc)
if le == 'windows':
assert b'\r\n' in result
elif le == 'unix':
assert b'\r\n' not in result
elif le == 'default':
assert os.linesep.encode(enc) in result
示例8:
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
# <markdowncell>
# There are 3 fruits in the list.
# <headingcell level=2>
# Saving an idf file
# <markdowncell>
# This is easy:
# <codecell>
idf1.save()
# <markdowncell>
# If you'd like to do a "Save as..." use this:
# <codecell>
idf1.saveas("something.idf")
# <headingcell level=2>
# Working with E+ objects
# <markdowncell>
示例9: IDF
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import save [as 别名]
idf_notemptyfile = IDF(fhandle) # initialize the IDF object with the file handle
idf_notemptyfile.printidf()
# <markdowncell>
# Aha !
#
# Now let us give it a file name
# <codecell>
# - give it a file name
idf_notemptyfile.idfname = "notemptyfile.idf"
# - Save it to the disk
idf_notemptyfile.save()
# <markdowncell>
# Let us confirm that the file was saved to disk
# <codecell>
txt = open("notemptyfile.idf", 'r').read()# read the file from the disk
print(txt)
# <markdowncell>
# Yup ! that file was saved. Let us delete it since we were just playing
# <codecell>