Skip to content
Snippets Groups Projects
Commit d9a06fcf authored by Bryan Brancotte's avatar Bryan Brancotte
Browse files

sanitize workflow name to be usable as a filename

parent 8317e93b
No related branches found
No related tags found
1 merge request!6Sanitize RO-Crate filename
Pipeline #13222 passed with stage
in 42 seconds
...@@ -155,5 +155,9 @@ class RO_Crate: ...@@ -155,5 +155,9 @@ class RO_Crate:
self.fill_from_workflow() self.fill_from_workflow()
self.dico.pop("temp_directory") self.dico.pop("temp_directory")
with open(f"{self.workflow.get_output_dir()}/ro-crate-metadata-{self.workflow.get_name()}.json", 'w') as output_file : name = self.workflow.get_name()
name = name.replace('github.com/', '')
name = re.sub(r"^[ .]|[/<>:\"\\|?*]+|[ .]$", "-", name)
with open(f"{self.workflow.get_output_dir()}/ro-crate-metadata-{name}.json", 'w') as output_file :
json.dump(self.dico, output_file, indent=2) json.dump(self.dico, output_file, indent=2)
\ No newline at end of file
...@@ -6,7 +6,6 @@ from bioflow_insight_cli.main import cli ...@@ -6,7 +6,6 @@ from bioflow_insight_cli.main import cli
class TestCall(unittest.TestCase): class TestCall(unittest.TestCase):
def test_cli_works(self): def test_cli_works(self):
cli("./wf_test/main.nf", render_graphs=True) cli("./wf_test/main.nf", render_graphs=True)
cli("./wf_test/main.nf", render_graphs=False) cli("./wf_test/main.nf", render_graphs=False)
...@@ -18,3 +17,12 @@ class TestCall(unittest.TestCase): ...@@ -18,3 +17,12 @@ class TestCall(unittest.TestCase):
cli("./wf_test/main.nf", render_graphs=False, output_dir=str(my_results)) cli("./wf_test/main.nf", render_graphs=False, output_dir=str(my_results))
self.assertTrue(my_results.exists(), "Results should be there, output_dir not taken into account") self.assertTrue(my_results.exists(), "Results should be there, output_dir not taken into account")
def test_with_illegal_path_char_in_name(self):
with TemporaryDirectory() as my_temp_dir:
my_results = pathlib.Path(my_temp_dir) / "my_results"
cli(
"./wf_test/main.nf",
render_graphs=False,
output_dir=str(my_results),
name="https://github.com/blabla/toto:qsd!qsd%#sqdqsd"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment