当前位置: 首页>>代码示例>>Python>>正文


Python ParsedParameterFile.keys方法代码示例

本文整理汇总了Python中PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile.keys方法的典型用法代码示例。如果您正苦于以下问题:Python ParsedParameterFile.keys方法的具体用法?Python ParsedParameterFile.keys怎么用?Python ParsedParameterFile.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile的用法示例。


在下文中一共展示了ParsedParameterFile.keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Feature

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import keys [as 别名]
class Feature(object):
    def __init__(self):
        work = get_work()
        self.path = os.path.join(work.systemDir(), "surfaceFeatureExtractDict")
        self.dict = ParsedParameterFile(self.path)
        self.feature =  {
            "extractionMethod" : "extractFromSurface",
            "extractFromSurfaceCoeffs" : {"includedAngle" : "120" },
            "writeObj" : "no"}
        
    def getGeoms(self):
        return self.dict.keys()
        
    def addGeom(self, geom):    
        self.dict[geom + ".stl"] = self.feature
        self.dict.writeFile()
        
    def rmGeom(self, geom):  
        if geom in self.getGeoms():
            del self.dict[geom + ".stl"]
            self.dict.writeFile()        
开发者ID:zagl,项目名称:chtrun,代码行数:23,代码来源:Feature.py

示例2: run

# 需要导入模块: from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile [as 别名]
# 或者: from PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile import keys [as 别名]
    def run(self):
        if self.opts.template=="stdin" and self.opts.pickledFileRead=="stdin":
            self.error("Can't simultanously read pickled data and the tempalte from the standard input")

        content=None
        if self.opts.template=="stdin":
            content=sys.stdin.read()
        data=None
        if self.opts.pickledFileRead:
            data=self.readPickledData()
        fName=None

        if len(self.parser.getArgs())==2:
            if self.opts.pickledFileRead:
                self.error("old-format mode does not work with pickled input")
            if self.opts.outputFile:
                self.error("--output-file is not valid for the old format")
            # old school implementation
            fName=self.parser.getArgs()[0]
            vals=eval(self.parser.getArgs()[1])
            if type(vals)==str:
                # fix a problem with certain shells
                vals=eval(vals)

            if self.opts.template==None:
                template=fName+".template"
            else:
                template=self.opts.template

            if content:
                t=TemplateFileOldFormat(content=content)
            else:
                t=TemplateFileOldFormat(name=template)
        elif len(self.parser.getArgs())==0:
            if self.opts.template==None and self.opts.outputFile!=None  and self.opts.outputFile!="stdin":
                self.opts.template=self.opts.outputFile+".template"
                self.warning("Automatically setting template to",self.opts.template)
            vals={}
            if self.opts.useDefaults and self.opts.template!=None and self.opts.template!="stdin":
                name,ext=path.splitext(self.opts.template)
                defaultName=name+".defaults"
                if path.exists(defaultName):
                    self.warning("Reading default values from",defaultName)
                    vals=ParsedParameterFile(defaultName,
                                             noHeader=True,
                                             doMacroExpansion=True).getValueDict()

            vals.update(self.parameters)

            if self.opts.values:
                vals.update(eval(self.opts.values))
            elif self.opts.valuesDict:
                vals.update(ParsedParameterFile(self.opts.valuesDict,
                                                noHeader=True,
                                                doMacroExpansion=True).getValueDict())
            elif data:
                vals.update(data["values"])
            elif len(self.parameters)==0:
                self.error("Either specify the values with --values-string or --values-dictionary or in the pickled input data")

            if self.opts.dumpUsed:
                maxLen=max([len(k) for k in vals.keys()])
                formatString=" %%%ds | %%s" % maxLen
                print_("Used values")
                print_(formatString % ("Name","Value"))
                print_("-"*(maxLen+30))
                for k,v in iteritems(vals):
                    print_(formatString % (k,v))

            if content:
                t=TemplateFile(content=content,
                               tolerantRender=self.opts.tolerantRender,
                               allowExec=self.opts.allowExec,
                               expressionDelimiter=self.opts.expressionDelimiter,
                               assignmentLineStart=self.opts.assignmentLineStart)
            elif data:
                t=TemplateFile(content=data["template"],
                               tolerantRender=self.opts.tolerantRender,
                               allowExec=self.opts.allowExec,
                               expressionDelimiter=self.opts.expressionDelimiter,
                               assignmentLineStart=self.opts.assignmentLineStart)
            elif self.opts.template:
                t=TemplateFile(name=self.opts.template,
                               tolerantRender=self.opts.tolerantRender,
                               allowExec=self.opts.allowExec,
                               expressionDelimiter=self.opts.expressionDelimiter,
                               assignmentLineStart=self.opts.assignmentLineStart)
            else:
                self.error("Template unspecified")

            if self.opts.outputFile:
                fName=self.opts.outputFile
        else:
            self.error("Either specify 2 arguments (file and values) for old format or no arguments for the new format")

        if self.opts.stdout:
            print_(t.getString(vals))
        elif fName:
            try:
                t.writeToFile(fName,vals)
#.........这里部分代码省略.........
开发者ID:martinep,项目名称:foam-extend-svn,代码行数:103,代码来源:FromTemplate.py


注:本文中的PyFoam.RunDictionary.ParsedParameterFile.ParsedParameterFile.keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。