diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-12-18 12:32:58 +0000 |
---|---|---|
committer | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-12-18 12:57:07 +0000 |
commit | d3c0a7d0223f6a0b7440091a4ac76a0c4d4d5fd1 (patch) | |
tree | cd4c1012d8c905e11fbc1bda02fa606b0b0c9cb4 | |
parent | 0b5ed7dbd862754e972657d4ffe4084fd3aa8593 (diff) | |
download | buildstream-d3c0a7d0223f6a0b7440091a4ac76a0c4d4d5fd1.tar.gz |
Try new copytree api on 3.8tpollard/python38
-rw-r--r-- | src/buildstream/testing/repo.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/buildstream/testing/repo.py b/src/buildstream/testing/repo.py index 1b46ec806..264dde4e2 100644 --- a/src/buildstream/testing/repo.py +++ b/src/buildstream/testing/repo.py @@ -84,13 +84,20 @@ class Repo: src (str): The source directory dest (str): The destination directory """ - for filename in os.listdir(src): - src_path = os.path.join(src, filename) - dest_path = os.path.join(dest, filename) - if os.path.isdir(src_path): - shutil.copytree(src_path, dest_path) - else: - shutil.copy2(src_path, dest_path) + + # Try to use copytree new api in 3.8 + import sys + + if sys.version_info[:2] < (3, 8): + for filename in os.listdir(src): + src_path = os.path.join(src, filename) + dest_path = os.path.join(dest, filename) + if os.path.isdir(src_path): + shutil.copytree(src_path, dest_path) + else: + shutil.copy2(src_path, dest_path) + else: + shutil.copytree(src, dest, dirs_exist_ok=True) # pylint: disable=unexpected-keyword-arg def copy(self, dest): """Creates a copy of this repository in the specified destination. |