Skip to content
Snippets Groups Projects
Commit 2ce952e1 authored by George Marchment's avatar George Marchment
Browse files

Merge branch 'sanitize-filename' into 'main'

Sanitize RO-Crate filename

See merge request !6
parents c2813083 d9a06fcf
No related branches found
No related tags found
1 merge request!6Sanitize RO-Crate filename
Pipeline #13227 passed with stages
in 1 minute and 29 seconds
......@@ -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
......@@ -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"
)
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