本文整理汇总了Python中eppy.modeleditor.IDF.idfname方法的典型用法代码示例。如果您正苦于以下问题:Python IDF.idfname方法的具体用法?Python IDF.idfname怎么用?Python IDF.idfname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eppy.modeleditor.IDF
的用法示例。
在下文中一共展示了IDF.idfname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_savecopy
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import idfname [as 别名]
def test_savecopy():
"""Test the IDF.savecopy() function.
"""
file_text = "Material,TestMaterial, !- Name"
idf = IDF(StringIO(file_text))
idf.idfname = 'test.idf'
try:
idf.savecopy() # this should raise an error as no filename is passed
assert False
except TypeError:
pass
file_handle = StringIO()
idf.savecopy(file_handle) # save a copy with a different filename
expected = "TestMaterial"
file_handle.seek(0)
result = file_handle.read()
assert expected in result
# test the idfname attribute has not been changed
assert idf.idfname == 'test.idf'
示例2: StringIO
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import idfname [as 别名]
idftxt = "VERSION, 7.3;" # Not an emplty string. has just the version number
fhandle = StringIO(idftxt) # we can make a file handle of a string
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