コード例 #1
0
 def testGitSubmoduleInfo(self):
     root = mooseutils.git_root_dir()
     status = mooseutils.git_submodule_info(root)
     self.assertIn('large_media', status)
     self.assertIn('libmesh', status)
     self.assertIn('petsc', status)
     self.assertEqual(len(status['large_media']), 3)
     self.assertEqual(len(status['libmesh']), 3)
     self.assertEqual(len(status['petsc']), 3)
コード例 #2
0
ファイル: gitutils.py プロジェクト: loganharbour/moose
    def createToken(self, parent, info, page, settings):
        inline = 'inline' in info
        if not inline:
            raise exceptions.MooseDocsException("The '!git submodule-hash' command is an inline level command, use '[!git!submodule-hash](name)' instead.")

        name = info['inline']
        status = mooseutils.git_submodule_info(MooseDocs.ROOT_DIR, '--recursive')
        for repo, ginfo in status.items():
            if repo.endswith(name):
                url = settings['url']
                if url is None:
                    core.Word(parent, content=ginfo[1])
                else:
                    core.Link(parent, url=f"{url.rstrip('/')}/{ginfo[1]}", string=ginfo[1])
                return parent

        msg = "The submodule '{}' was not located, the available submodules are: {}"
        raise exceptions.MooseDocsException(msg, name, ', '.join(status.keys()))
コード例 #3
0
ファイル: ifelse.py プロジェクト: loganharbour/moose
 def hasSubmodule(self, name):
     """Helper for the 'hasSubmodule' function."""
     status = mooseutils.git_submodule_info(MooseDocs.ROOT_DIR, '--recursive')
     return any([repo.endswith(name) for repo in status.keys()])
コード例 #4
0
import os
import sys
import subprocess
import mooseutils

try:
    import hit

except ImportError:

    # If the repository is not a git repository, then give up otherwise try to figure out what to do
    if not mooseutils.is_git_repo(os.path.dirname(__file__)):
        raise

    moose_dir = mooseutils.git_root_dir(os.path.dirname(__file__))
    status = mooseutils.git_submodule_info(moose_dir)

    # Use framework/contrib/hit because moosetools submodule is not available
    if status['moosetools'][0] == '-':
        hit_dir = os.path.join(moose_dir, 'framework', 'contrib', 'hit')
        sys.path.append(hit_dir)
        try:
            import hit
        except ImportError:
            moose_test_dir = os.path.abspath(os.path.join(moose_dir, 'test'))
            subprocess.run(['make', 'hit'], cwd=moose_test_dir)
            import hit
    # Use hit in moosetools submodule
    else:
        hit_dir = os.path.join(moose_dir, 'moosetools', 'contrib', 'hit')
        sys.path.append(hit_dir)