Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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