Beispiel #1
0
 def testMooseError(self):
     """
     Tests mooseError function.
     """
     message.mooseError("Don't do it!")
     output = sys.stdout.getvalue()
     err = sys.stderr.getvalue()
     self.assertIn('ERROR', output)
     self.assertIn("Don't do it!", output)
     self.assertIn("in mooseError", err)
     self.assertIn('\033[31m', output)
 def testMooseError(self):
     """
     Tests mooseError function.
     """
     message.mooseError("Don't do it!")
     output = sys.stdout.getvalue()
     err = sys.stderr.getvalue()
     self.assertIn('ERROR', output)
     self.assertIn("Don't do it!", output)
     self.assertIn("in mooseError", err)
     self.assertIn('\033[31m', output)
Beispiel #3
0
def load(filename, root=None):
    """
    Read and parse a HIT file given in *filename*.

    The function return a `pyhit.Node` object which is the root node of the loaded tree. The
    specific node object that should be populated can be supplied with the *root* input. If it is
    provided this same node will be returned.
    """
    if os.path.exists(filename):
        with open(filename, 'r') as fid:
            content = fid.read()
    elif isinstance(filename, str):
        content = filename
    else:
        message.mooseError("Unable to load the hit file ", filename)

    return parse(content, root, filename)
Beispiel #4
0
def load(filename, root=None):
    """
    Read and parse a hit file (MOOSE input file format).

    Inputs:
        filename[str]: The filename to open and parse.
        root[Node]: (Optional) The root node of the tree

    Returns a Node object, which is the root of the tree. Node objects are custom
    versions of the moosetree.Node objects.
    """
    if os.path.exists(filename):
        with open(filename, 'r') as fid:
            content = fid.read()
    elif isinstance(filename, str):
        content = filename
    else:
        message.mooseError("Unable to load the hit file ", filename)

    return parse(content, root, filename)