diff options
author | Lucian Petrut <lpetrut@cloudbasesolutions.com> | 2019-05-31 15:06:56 +0300 |
---|---|---|
committer | Lucian Petrut <lpetrut@cloudbasesolutions.com> | 2019-05-31 15:35:45 +0300 |
commit | a7e5c0202ea00aab29c009f7adef6cea51ac6e25 (patch) | |
tree | d7c60d39c5a8923e19336babdb12b149c531eae4 /pbr/hooks | |
parent | c1e4225c5a5b9917c62f84d3ae56e747e2758f69 (diff) | |
download | pbr-a7e5c0202ea00aab29c009f7adef6cea51ac6e25.tar.gz |
Fix Windows support
A recent commit [1] broke Windows support by using shlex to
unquote paths.
The issue with shlex.split is that it doesn't work with Windows
paths, treating backslashes as escape characters.
We'll just replace backslashes with slashes before using shlex.split,
converting them back afterwards.
Closes-Bug: #1831242
[1] Id2cc32e4e40c1f834b19756e922118d8526358d3
Change-Id: Icb3abca004a35ab9760db8116fedfa96d012d0d0
Diffstat (limited to 'pbr/hooks')
-rw-r--r-- | pbr/hooks/files.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pbr/hooks/files.py b/pbr/hooks/files.py index 0fe0df5..c44af7c 100644 --- a/pbr/hooks/files.py +++ b/pbr/hooks/files.py @@ -41,6 +41,13 @@ def unquote_path(path): # strip the quotes off individual path components because os.walk cannot # handle paths like: "'i like spaces'/'another dir'", so we will pass it # "i like spaces/another dir" instead. + + if os.name == 'nt': + # shlex cannot handle paths that contain backslashes, treating those + # as escape characters. + path = path.replace("\\", "/") + return "".join(shlex.split(path)).replace("/", "\\") + return "".join(shlex.split(path)) |