Пример #1
0
 def testDiffusion(self):
     database = build_class_database()
     info = database['Diffusion']
     self.assertEqual(info.header, 'framework/include/kernels/Diffusion.h')
     self.assertEqual(info.source, 'framework/src/kernels/Diffusion.C')
     self.assertIn('modules/heat_conduction/include/kernels/HeatConduction.h', info.children)
     self.assertIn('test/tests/mesh/named_entities/named_entities_test_xda.i', info.inputs)
Пример #2
0
    def __initClassDatabase(self):
        """Initialize the class database for faster searching."""

        # Do nothing if the syntax failed to build
        if self._app_syntax is None:
            return

        start = time.time()
        LOG.info("Building MOOSE class database...")
        self._database = common.build_class_database(self['includes'],
                                                     self['inputs'])

        # Cache the syntax entries, search the tree is very slow
        self._cache = dict()
        self._object_cache = dict()
        self._syntax_cache = dict()
        for node in anytree.PreOrderIter(self._app_syntax):
            if not node.removed:
                self._cache[node.fullpath] = node
                if node.alias:
                    self._cache[node.alias] = node
                if isinstance(node, syntax.ObjectNode):
                    self._object_cache[node.fullpath] = node
                    if node.alias:
                        self._object_cache[node.alias] = node
                elif isinstance(node, syntax.SyntaxNode):
                    self._syntax_cache[node.fullpath] = node
                    if node.alias:
                        self._syntax_cache[node.alias] = node
        LOG.info("MOOSE class database complete [%s sec]", time.time() - start)
Пример #3
0
 def setUpClass(cls):
     """
     Create class database.
     """
     cls.database = build_class_database(['${MOOSE_DIR}/framework/include',
                                          '${MOOSE_DIR}/modules/heat_conduction/include'],
                                         ['${MOOSE_DIR}/test/tests'])
Пример #4
0
    def __initClassDatabase(self):
        """Initialize the class database for faster searching."""

        # Do nothing if the syntax failed to build
        if self._app_syntax is None:
            return

        start = time.time()
        LOG.info("Building MOOSE class database...")
        self._database = common.build_class_database(self['includes'], self['inputs'])

        # Cache the syntax entries, search the tree is very slow
        self._cache = dict()
        self._object_cache = dict()
        self._syntax_cache = dict()
        for node in anytree.PreOrderIter(self._app_syntax):
            if not node.removed:
                self._cache[node.fullpath] = node
                if node.alias:
                    self._cache[node.alias] = node
                if isinstance(node, syntax.ObjectNode):
                    self._object_cache[node.fullpath] = node
                    if node.alias:
                        self._object_cache[node.alias] = node
                elif isinstance(node, syntax.SyntaxNode):
                    self._syntax_cache[node.fullpath] = node
                    if node.alias:
                        self._syntax_cache[node.alias] = node
        LOG.info("MOOSE class database complete [%s sec]", time.time() - start)
Пример #5
0
    def __init__(self, *args, **kwargs):
        command.CommandExtension.__init__(self, *args, **kwargs)

        self._app_type = None
        self._app_syntax = None
        if not self['disable'] and self['executable'] is not None:
            LOG.info("Reading MOOSE application syntax.")
            exe = mooseutils.eval_path(self['executable'])
            exe = mooseutils.find_moose_executable(exe, show_error=False)

            if exe is None:
                LOG.error("Failed to locate a valid executable in %s.",
                          self['executable'])
            else:
                try:
                    self._app_syntax = app_syntax(
                        exe,
                        alias=self['alias'],
                        remove=self['remove'],
                        hide=self['hide'],
                        allow_test_objects=self['allow-test-objects'])

                    out = mooseutils.runExe(exe, ['--type'])
                    match = re.search(r'^MooseApp Type:\s+(?P<type>.*?)$',
                                      out,
                                      flags=re.MULTILINE)
                    if match:
                        self._app_type = match.group("type")
                    else:
                        msg = "Failed to determine application type by running the following:\n"
                        msg += "    {} --type".format(exe)
                        LOG.error(msg)

                except Exception as e:  #pylint: disable=broad-except
                    msg = "Failed to load application executable from '%s', " \
                          "application syntax is being disabled:\n%s"
                    LOG.error(msg, self['executable'], e.message)

        LOG.info("Building MOOSE class database.")
        self._database = common.build_class_database(self['includes'],
                                                     self['inputs'])

        # Cache the syntax entries, search the tree is very slow
        if self._app_syntax:
            self._cache = dict()
            self._object_cache = dict()
            self._syntax_cache = dict()
            for node in anytree.PreOrderIter(self._app_syntax):
                if not node.removed:
                    self._cache[node.fullpath] = node
                    if node.alias:
                        self._cache[node.alias] = node
                    if isinstance(node, syntax.ObjectNode):
                        self._object_cache[node.fullpath] = node
                        if node.alias:
                            self._object_cache[node.alias] = node
                    elif isinstance(node, syntax.SyntaxNode):
                        self._syntax_cache[node.fullpath] = node
                        if node.alias:
                            self._syntax_cache[node.alias] = node
Пример #6
0
 def setUpClass(cls):
     """
     Create class database.
     """
     cls.database = build_class_database([
         '${MOOSE_DIR}/framework/include',
         '${MOOSE_DIR}/modules/heat_conduction/include'
     ], ['${MOOSE_DIR}/test/tests'])
Пример #7
0
 def testDiffusion(self):
     database = build_class_database()
     info = database['Diffusion']
     self.assertEqual(info.header, 'framework/include/kernels/Diffusion.h')
     self.assertEqual(info.source, 'framework/src/kernels/Diffusion.C')
     self.assertIn(
         'modules/heat_conduction/include/kernels/HeatConduction.h',
         info.children)
     self.assertIn(
         'test/tests/mesh/named_entities/named_entities_test_xda.i',
         info.inputs)
Пример #8
0
    def __init__(self, *args, **kwargs):
        command.CommandExtension.__init__(self, *args, **kwargs)

        self._app_type = None
        self._app_syntax = None
        if not self['disable'] and self['executable'] is not None:
            LOG.info("Reading MOOSE application syntax.")
            exe = mooseutils.eval_path(self['executable'])
            exe = mooseutils.find_moose_executable(exe, show_error=False)

            if exe is None:
                LOG.error("Failed to locate a valid executable in %s.", self['executable'])
            else:
                try:
                    self._app_syntax = app_syntax(exe,
                                                  alias=self['alias'],
                                                  remove=self['remove'],
                                                  hide=self['hide'],
                                                  allow_test_objects=self['allow-test-objects'])

                    self._app_type = mooseutils.runExe(exe, ['--type']).strip(' \n')

                except Exception as e: #pylint: disable=broad-except
                    msg = "Failed to load application executable from '%s', " \
                          "application syntax is being disabled:\n%s"
                    LOG.error(msg, self['executable'], e.message)

        LOG.info("Building MOOSE class database.")
        self._database = common.build_class_database(self['includes'], self['inputs'])

        # Cache the syntax entries, search the tree is very slow
        if self._app_syntax:
            self._cache = dict()
            self._object_cache = dict()
            self._syntax_cache = dict()
            for node in anytree.PreOrderIter(self._app_syntax):
                if not node.removed:
                    self._cache[node.fullpath] = node
                    if node.alias:
                        self._cache[node.alias] = node
                    if isinstance(node, syntax.ObjectNode):
                        self._object_cache[node.fullpath] = node
                        if node.alias:
                            self._object_cache[node.alias] = node
                    elif isinstance(node, syntax.SyntaxNode):
                        self._syntax_cache[node.fullpath] = node
                        if node.alias:
                            self._syntax_cache[node.alias] = node
Пример #9
0
    def __init__(self, *args, **kwargs):
        command.CommandExtension.__init__(self, *args, **kwargs)

        self._app_type = None
        self._app_syntax = None
        if not self['disable'] and self['executable'] is not None:
            LOG.info("Reading MOOSE application syntax.")
            exe = mooseutils.eval_path(self['executable'])
            exe = mooseutils.find_moose_executable(exe, show_error=False)

            if exe is None:
                LOG.error("Failed to locate a valid executable in %s.", self['executable'])
            else:
                try:
                    self._app_syntax = app_syntax(exe,
                                                  alias=self['alias'],
                                                  remove=self['remove'],
                                                  hide=self['hide'],
                                                  allow_test_objects=self['allow-test-objects'])

                    self._app_type = mooseutils.runExe(exe, ['--type']).strip(' \n')

                except Exception as e: #pylint: disable=broad-except
                    msg = "Failed to load application executable from '%s', " \
                          "application syntax is being disabled:\n%s"
                    LOG.error(msg, self['executable'], e.message)

        LOG.info("Building MOOSE class database.")
        self._database = common.build_class_database(self['includes'], self['inputs'])

        # Cache the syntax entries, search the tree is very slow
        if self._app_syntax:
            self._cache = dict()
            self._object_cache = dict()
            self._syntax_cache = dict()
            for node in anytree.PreOrderIter(self._app_syntax):
                if not node.removed:
                    self._cache[node.fullpath] = node
                    if isinstance(node, syntax.ObjectNode):
                        self._object_cache[node.fullpath] = node
                    elif isinstance(node, syntax.SyntaxNode):
                        self._syntax_cache[node.fullpath] = node
Пример #10
0
 def setUpClass(cls):
     """
     Create class database.
     """
     cls.database = build_class_database('${MOOSE_DIR}/framework/include',
                                         '${MOOSE_DIR}/test/tests')