diff --git a/changelog.txt b/changelog.txt index 34db5be53..e5b1f2ad2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,14 @@ The **signac** package follows `semantic versioning `_. Version 2 ========= +[2.2.0] -- 2023-xx-xx +--------------------- + +Changed ++++++++ + + - linked views now can contain spaces and other characters except directory separators (#926). + [2.1.0] -- 2023-07-12 --------------------- diff --git a/signac/linked_view.py b/signac/linked_view.py index b4d4a7258..ab273a721 100644 --- a/signac/linked_view.py +++ b/signac/linked_view.py @@ -41,7 +41,7 @@ def create_linked_view(project, prefix=None, job_ids=None, path=None): Linked views cannot be created on Windows because symbolic links are not supported by the platform. RuntimeError - When state points contain one of ``[os.sep, " ", "*"]``. + When state points contain ``os.sep``. """ from .import_export import _check_directory_structure_validity, _make_path_function @@ -64,19 +64,13 @@ def create_linked_view(project, prefix=None, job_ids=None, path=None): key_list = [k for job in jobs for k in job.statepoint().keys()] value_list = [v for job in jobs for v in job.statepoint().values()] item_list = key_list + value_list - bad_chars = [os.sep, " ", "*"] - bad_items = [ - item - for item in item_list - for char in bad_chars - if isinstance(item, str) and char in item - ] + bad_items = [item for item in item_list if isinstance(item, str) and os.sep in item] if any(bad_items): err_msg = " ".join( [ - f"In order to use view, state points should not contain {bad_chars}:", - *bad_items, + f"In order to use view, state points should not contain {os.sep}:", + str(set(bad_items)), ] ) raise RuntimeError(err_msg) diff --git a/tests/test_project.py b/tests/test_project.py index e268c4f95..565a2d5bc 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -2038,13 +2038,22 @@ def test_create_linked_view_heterogeneous_schema_problematic(self): @pytest.mark.skipif(WINDOWS, reason="Linked views unsupported on Windows.") def test_create_linked_view_with_slash_raises_error(self): - bad_chars = [os.sep, " ", "*"] - statepoints = [{f"a{i}b": 0, "b": f"bad{i}val"} for i in bad_chars] + statepoint = {"b": f"bad{os.sep}val"} + view_prefix = os.path.join(self._tmp_pr, "view") + self.project.open_job(statepoint).init() + with pytest.raises(RuntimeError): + self.project.create_linked_view(prefix=view_prefix) + + @pytest.mark.skipif(WINDOWS, reason="Linked views unsupported on Windows.") + def test_create_linked_view_weird_chars_in_file_name(self): + shell_escaped_chars = [" ", "*", "~"] + statepoints = [ + {f"a{i}b": 0, "b": f"escaped{i}val"} for i in shell_escaped_chars + ] view_prefix = os.path.join(self._tmp_pr, "view") for sp in statepoints: self.project.open_job(sp).init() - with pytest.raises(RuntimeError): - self.project.create_linked_view(prefix=view_prefix) + self.project.create_linked_view(prefix=view_prefix) @pytest.mark.skipif(WINDOWS, reason="Linked views unsupported on Windows.") def test_create_linked_view_duplicate_paths(self):