You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:22:06 UTC
[buildstream] 08/08: Try new copytree api on 3.8
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch tpollard/python38
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit d3c0a7d0223f6a0b7440091a4ac76a0c4d4d5fd1
Author: Tom Pollard <to...@codethink.co.uk>
AuthorDate: Wed Dec 18 12:32:58 2019 +0000
Try new copytree api on 3.8
---
src/buildstream/testing/repo.py | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/buildstream/testing/repo.py b/src/buildstream/testing/repo.py
index 1b46ec8..264dde4 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.