def processABoundaryFile(self,func,targetDir):
        """
        @param func: the function that transforms the actual boundary file
        """
        boundaryPath=path.join(targetDir,self.opts.region,"polyMesh","boundary")
        try:
            boundary=ParsedParameterFile(boundaryPath,
                                         debug=False,
                                         boundaryDict=True,
                                         treatBinaryAsASCII=True)
        except IOError:
            self.warning("Problem opening boundary file",boundaryPath)
            return False

        bnd=boundary.content

        if type(bnd)!=list:
            self.warning("Problem with boundary file (not a list)")
            return False

        boundary.content=func(bnd,targetDir)

        if boundary.content:
            if self.opts.test:
                print_(boundary)
            else:
                boundary.writeFile()
                # self.addToCaseLog(boundaryPath)
            return True
        else:
            self.warning(boundaryPath,"unchanged")
            return False
Ejemplo n.º 2
0
    def processABoundaryFile(self,func,targetDir):
        """
        :param func: the function that transforms the actual boundary file
        """
        boundaryPath=path.join(targetDir,"polyMesh","boundary")
        try:
            boundary=ParsedParameterFile(boundaryPath,
                                         debug=False,
                                         boundaryDict=True,
                                         treatBinaryAsASCII=True)
        except IOError:
            self.warning("Problem opening boundary file",boundaryPath)
            return False

        bnd=boundary.content

        if type(bnd)!=list:
            self.warning("Problem with boundary file (not a list)")
            return False

        boundary.content=func(bnd,targetDir)

        if boundary.content:
            if self.opts.test:
                print_(boundary)
            else:
                boundary.writeFile()
                # self.addToCaseLog(boundaryPath)
            return True
        else:
            self.warning(boundaryPath,"unchanged")
            return False
Ejemplo n.º 3
0
    def upgrade(self,force,printIt):
        backup=self.path()+".upgradeBackup"
        if not printIt:
            if path.exists(backup):
                if not force:
                    error("The backup-file",backup,"does already exist")

            copyfile(self.path(),backup)
        f=ParsedParameterFile(self.path(),
                              listDict=self.listDict,
                              noHeader=self.noHeader)
        r=self.manipulate(f.content)
        if r:
            f.content=r
        if not printIt:
            f.writeFile()
        else:
            print_(f)