def testADObject(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'test') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe) node = moosetree.find(root, lambda n: n.fullpath == '/Kernels/ADDiffusion') self.assertEqual(node.fullpath, '/Kernels/ADDiffusion')
def testRemoveTestApp(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'modules', 'combined') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe) node = root.findfull('/UserObjects/TestDistributionPostprocessor') self.assertTrue(node.removed) self.assertIn('MiscTest', root.groups)
def __initApplicationSyntax(self): """Initialize the application syntax.""" start = time.time() 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" self.setActive(False) LOG.error(msg, self.get('executable'), e.message) LOG.info("MOOSE application syntax complete [%s sec.]", time.time() - start)
def testRemoveDisable(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'modules', 'combined') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe, remove=[]) node = anytree.search.find_by_attr( root, '/Variables/InitialCondition/BoundingBoxIC', name='fullpath') self.assertEqual(node.name, 'BoundingBoxIC')
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
def testRemoveDisable(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'modules', 'combined') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe, remove=[]) node = anytree.search.find_by_attr(root, '/Variables/InitialCondition/BoundingBoxIC', name='fullpath') self.assertEqual(node.name, 'BoundingBoxIC')
def main(options): """./moosedocs update""" # Load syntax exe = os.path.abspath(os.path.join(os.getcwd(), options.executable)) if os.path.isdir(exe): exe = mooseutils.find_moose_executable(exe) LOG.info("Loading application syntax: %s", exe) root = app_syntax(exe) # Determine group name group_dir = os.path.basename(exe).split('-')[0] group = group_dir.replace('_', ' ').title().replace(' ', '') if options.move: for node in anytree.PreOrderIter(root): if isinstance(node, syntax.ObjectNode) and group in node.groups: _move(node, group_dir, options) if options.update: for root, _, files in os.walk(MooseDocs.ROOT_DIR): for name in files: if name.endswith('.md'): filename = os.path.join(root, name) print 'Update:', filename _update(filename)
def testADObject(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'test') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe) node = anytree.search.find_by_attr(root, '/Kernels/ADDiffusion', name='fullpath') self.assertEqual(node.fullpath, '/Kernels/ADDiffusion')
def testAlias(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'test') exe = mooseutils.find_moose_executable(location) alias = dict() alias['/VectorPostprocessors/VolumeHistogram'] = '/VPP/VolumeHistogram' root = app_syntax(exe, alias=alias) node = root.findfull('/VPP/VolumeHistogram') self.assertEqual(node.fullpath, '/VPP/VolumeHistogram')
def testRemove(self): location = os.path.join(MooseDocs.MOOSE_DIR, 'modules', 'combined') exe = mooseutils.find_moose_executable(location) root = app_syntax(exe, remove=['/Variables/InitialCondition']) node = root.findfull('/Variables/InitialCondition/AddICAction') self.assertEqual(node.name, 'AddICAction') self.assertTrue(node.removed) node = root.findfull('/Variables/InitialCondition/BoundingBoxIC') self.assertTrue(node.removed)
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
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