Esempio n. 1
0
def test_docker2singularity(test_data, tmp_path):
    from spython.main.parse.parsers import DockerParser
    from spython.main.parse.writers import SingularityWriter

    for dockerfile, recipe in test_data["d2s"]:
        parser = DockerParser(dockerfile)
        writer = SingularityWriter(parser.recipe)
        assert writer.convert().strip("\n") == read_file(recipe)
Esempio n. 2
0
def test_singularity_writer(test_data):
    from spython.main.parse.parsers import SingularityParser

    recipe = os.path.join(test_data["root"], "Singularity")
    parser = SingularityParser(recipe)
    writer = SingularityWriter(parser.recipe)

    assert str(writer) == "[spython-writer][singularity]"
    print(writer.convert())
Esempio n. 3
0
    def _convert(dockerfile, singularityfile):
        parser = DockerParser(dockerfile)
        for p in parser.recipe.files:
            p[0] = p[0].strip('\"')
            p[1] = p[1].strip('\"')
            if os.path.isdir(p[0]):
                p[0] += '/.'

        writer = SingularityWriter(parser.recipe)
        recipe = writer.convert()
        with open(singularityfile, 'w') as sf:
            sf.write(recipe)
        return singularityfile
Esempio n. 4
0
    def convert(dockerfile, singularityfile):
        """Convert a Dockerfile to a Singularity recipe file.

        Args:
            dockerfile (str): The path to the Dockerfile.
            singularityfile (str): The path to the Singularity recipe.

        Returns:
            str: The Singularity recipefile path.
        """
        parser = DockerParser(dockerfile)
        for p in parser.recipe.files:
            p[0] = p[0].strip('\"')
            p[1] = p[1].strip('\"')
            if os.path.isdir(p[0]):
                p[0] += '/.'

        writer = SingularityWriter(parser.recipe)
        recipe = writer.convert()
        with open(singularityfile, 'w') as sf:
            sf.write(recipe)
        return singularityfile