Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-02-16 06:02:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-16 07:58:34 +0300
commitf34d5d99dce8dde6559e7d5ebd8060cc942a7491 (patch)
tree7b0f044edf58d6b194cd9e67ccbc1c6f725a6cef
parent4a784f32fe1ef2792e05c9a4fc277f6f84baaaec (diff)
Cleanup: remove local copy of shutil.copytree from Python 3.8
-rw-r--r--release/scripts/startup/bl_operators/userpref.py49
1 files changed, 2 insertions, 47 deletions
diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py
index fa6338fa614..7f2fa1292ee 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -50,49 +50,6 @@ def module_filesystem_remove(path_base, module_name):
os.remove(f_full)
-# This duplicates shutil.copytree from Python 3.8, with the new dirs_exist_ok
-# argument that we need. Once we upgrade to 3.8 we can remove this.
-def _preferences_copytree(entries, src, dst):
- import os
- import shutil
- from shutil import Error
-
- os.makedirs(dst, exist_ok=True)
- errors = []
-
- for srcentry in entries:
- srcname = os.path.join(src, srcentry.name)
- dstname = os.path.join(dst, srcentry.name)
- srcobj = srcentry
- try:
- if srcentry.is_symlink():
- linkto = os.readlink(srcname)
- os.symlink(linkto, dstname)
- shutil.copystat(srcobj, dstname, follow_symlinks=False)
- elif srcentry.is_dir():
- preferences_copytree(srcobj, dstname)
- else:
- shutil.copy2(srcentry, dstname)
- except Error as err:
- errors.extend(err.args[0])
- except OSError as why:
- errors.append((srcname, dstname, str(why)))
- try:
- shutil.copystat(src, dst)
- except OSError as why:
- if getattr(why, 'winerror', None) is None:
- errors.append((src, dst, str(why)))
- if errors:
- raise Error(errors)
- return dst
-
-
-def preferences_copytree(src, dst):
- import os
- with os.scandir(src) as entries:
- return _preferences_copytree(entries=entries, src=src, dst=dst)
-
-
class PREFERENCES_OT_keyconfig_activate(Operator):
bl_idname = "preferences.keyconfig_activate"
bl_label = "Activate Keyconfig"
@@ -168,10 +125,8 @@ class PREFERENCES_OT_copy_prev(Operator):
return os.path.isfile(old_userpref) and not os.path.isfile(new_userpref)
def execute(self, _context):
- # Use this instead once we upgrade to Python 3.8 with dirs_exist_ok.
- # import shutil
- # shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True)
- preferences_copytree(self._old_path(), self._new_path())
+ import shutil
+ shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True)
# reload preferences and recent-files.txt
bpy.ops.wm.read_userpref()