From 4f21fe22d4a09e228e50ce2fcb6e86dc5a38ea38 Mon Sep 17 00:00:00 2001 From: "daniel.asztalos" Date: Fri, 29 Mar 2019 11:14:13 +0100 Subject: [PATCH 1/2] Fix path list with whitespace --- src/rez/config.py | 4 ++++ src/rez/tests/test_config.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/rez/config.py b/src/rez/config.py index f0f096175..f7449c072 100644 --- a/src/rez/config.py +++ b/src/rez/config.py @@ -126,6 +126,10 @@ class OptionalStrList(StrList): class PathList(StrList): sep = os.pathsep + def _parse_env_var(self, value): + value = value.split(self.sep) + return [x for x in value if x] + class Int(Setting): schema = Schema(int) diff --git a/src/rez/tests/test_config.py b/src/rez/tests/test_config.py index 37f0e8ff6..0c649042a 100644 --- a/src/rez/tests/test_config.py +++ b/src/rez/tests/test_config.py @@ -226,6 +226,19 @@ def _data(self): finally: os.environ = old_environ + def test_7(self): + """Test path list environment variable with whitespace.""" + c = Config([self.root_config_file], locked=False) + + # test basic env-var override + packages_path = [ + "c:/foo bar/baz", + "c:/foo 2 bar/baz", + ] + os.environ["REZ_PACKAGES_PATH"] = os.pathsep.join(packages_path) + + self.assertEqual(c.packages_path, packages_path) + if __name__ == '__main__': unittest.main() From 0c7dc254aeaae19b140c3669252d148366524563 Mon Sep 17 00:00:00 2001 From: "daniel.asztalos" Date: Fri, 29 Mar 2019 16:36:39 +0100 Subject: [PATCH 2/2] some more paths to test --- src/rez/tests/test_config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rez/tests/test_config.py b/src/rez/tests/test_config.py index 0c649042a..cb5c2f45c 100644 --- a/src/rez/tests/test_config.py +++ b/src/rez/tests/test_config.py @@ -234,6 +234,9 @@ def test_7(self): packages_path = [ "c:/foo bar/baz", "c:/foo 2 bar/baz", + r"c:\foo bar\baz", + "/home/foo bar/baz", + r"/home/foo\ bar/baz" ] os.environ["REZ_PACKAGES_PATH"] = os.pathsep.join(packages_path)