本文整理汇总了Python中PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile.getCaseDir方法的典型用法代码示例。如果您正苦于以下问题:Python ParsedParameterFile.getCaseDir方法的具体用法?Python ParsedParameterFile.getCaseDir怎么用?Python ParsedParameterFile.getCaseDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile
的用法示例。
在下文中一共展示了ParsedParameterFile.getCaseDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import getCaseDir [as 别名]
def run(self):
sName=path.abspath(self.parser.getArgs()[0])
dName=path.abspath(self.parser.getArgs()[1])
if self.opts.all:
self.opts.append=True
self.opts.shorten=True
self.opts.add=True
self.opts.clear=True
try:
source=ParsedParameterFile(sName,
backup=False,
debug=self.opts.debugParser,
noBody=self.opts.noBody,
noHeader=self.opts.noHeader,
boundaryDict=self.opts.boundaryDict,
listDict=self.opts.listDict,
listDictWithHeader=self.opts.listDictWithHeader)
except IOError:
e = sys.exc_info()[1] # Needed because python 2.5 does not support 'as e'
self.error("Problem with file",sName,":",e)
if not self.opts.notequal and path.basename(sName)!=path.basename(dName):
found=False
parts=sName.split(path.sep)
for i in range(len(parts)):
tmp=path.join(*[dName]+parts[-(i+1):])
if path.exists(tmp):
found=True
dName=tmp
warning("Found",dName,"and using this")
break
if not found:
error("Could not find a file named",path.basename(sName),"in",dName)
if path.samefile(sName,dName):
error("Source",sName,"and destination",dName,"are the same")
try:
dest=ParsedParameterFile(dName,
backup=False,
debug=self.opts.debugParser,
noBody=self.opts.noBody,
noHeader=self.opts.noHeader,
boundaryDict=self.opts.boundaryDict,
listDict=self.opts.listDict,
listDictWithHeader=self.opts.listDictWithHeader)
except IOError:
e = sys.exc_info()[1] # Needed because python 2.5 does not support 'as e'
self.error("Problem with file",dName,":",e)
dCase=dest.getCaseDir()
if self.opts.interactive:
self.opts.verbose=True
if not self.opts.boundaryDict and not self.opts.listDict and not self.opts.listDictWithHeader:
self.workDict(source.content,dest.content,1)
else:
self.workList(source.content,dest.content,1)
if self.opts.test or self.opts.interactive:
print_(str(dest))
if not self.opts.test and self.ask("\n Write this file to disk"):
dest.writeFile()
if dCase!=None:
self.addToCaseLog(dCase,"Source",sName,"Destination:",dName)