def getInputFileFormat(self, extra=[]):
     """
     Does a dump and uses the GetPotParser to parse the output.
     """
     args = ["--dump"] + extra
     output = run_app(args)
     self.assertNotEqual(len(output), 0)
     with open("dump.i", "w") as f:
         f.write(output)
     return readInputFile("dump.i")
示例#2
0
 def getInputFileFormat(self, extra=[]):
     """
     Does a dump and uses the GetPotParser to parse the output.
     """
     args = ["--dump"] + extra
     output = run_app(args)
     self.assertNotEqual(len(output), 0)
     with open("dump.i", "w") as f:
         f.write(output)
     return readInputFile("dump.i")
示例#3
0
    def openInputFile(self, filename):
        """
        Opens a file and parses it.
        Input:
            filename: file name of the input file
        Signals:
            input_file_changed: On success
        Raises:
            PeacockException: On invalid input file
        """
        filename = str(filename)
        self.filename = path.abspath(filename)
        self.changed = False
        self.root_node = GPNode("/", None)

        # Do some basic checks on the filename to make sure
        # it is probably a real input file since the GetPot
        # parser doesn't do any checks.
        if not path.exists(filename):
            msg = "Input file %s does not exist" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        if not path.isfile(filename):
            msg = "Input file %s is not a file" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        if not filename.endswith(".i"):
            msg = "Input file %s does not have the proper extension" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        try:
            self.root_node = readInputFile(filename)
            with open(filename, "r") as f:
                self.original_text = f.read()
            self.changed = False
        except ParseException as e:
            msg = "Failed to parse input file %s:\n%s\n" % (filename, e.msg)
            mooseutils.mooseWarning(msg)
            raise e
        except Exception as e:
            msg = "Error occurred while parsing input file %s:\n%s\n" % (
                filename, e)
            mooseutils.mooseWarning(msg)
            raise e
示例#4
0
    def openInputFile(self, filename):
        """
        Opens a file and parses it.
        Input:
            filename: file name of the input file
        Signals:
            input_file_changed: On success
        Raises:
            PeacockException: On invalid input file
        """
        filename = str(filename)
        self.filename = path.abspath(filename)
        self.changed = False
        self.root_node = GPNode("/", None)

        # Do some basic checks on the filename to make sure
        # it is probably a real input file since the GetPot
        # parser doesn't do any checks.
        if not path.exists(filename):
            msg = "Input file %s does not exist" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        if not path.isfile(filename):
            msg = "Input file %s is not a file" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        if not filename.endswith(".i"):
            msg = "Input file %s does not have the proper extension" % filename
            mooseutils.mooseError(msg)
            raise PeacockException(msg)

        try:
            self.root_node = readInputFile(filename)
            with open(filename, "r") as f:
                self.original_text = f.read()
            self.changed = False
        except ParseException as e:
            msg = "Failed to parse input file %s:\n%s\n" % (filename, e.msg)
            mooseutils.mooseWarning(msg)
            raise e
        except Exception as e:
            msg = "Error occurred while parsing input file %s:\n%s\n" % (filename, e)
            mooseutils.mooseWarning(msg)
            raise e