diff --git a/src/ro_crate.py b/src/ro_crate.py index 6330b41360c657e60d60190a7bd040b159830ede..22c117923dcc9dd79caba53aaf0287f67644f72d 100644 --- a/src/ro_crate.py +++ b/src/ro_crate.py @@ -155,5 +155,9 @@ class RO_Crate: self.fill_from_workflow() 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) \ No newline at end of file diff --git a/tests/test_cli.py b/tests/test_cli.py index 04db2ce966d32132ac378841734805890bc444a4..076721cecca10563ff6b3698c182db0c12ac49e5 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -6,7 +6,6 @@ from bioflow_insight_cli.main import cli class TestCall(unittest.TestCase): - def test_cli_works(self): cli("./wf_test/main.nf", render_graphs=True) cli("./wf_test/main.nf", render_graphs=False) @@ -18,3 +17,12 @@ class TestCall(unittest.TestCase): 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") + 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" + )