mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
stop messing with distutils's internal just to copy directory (#3364)
This commit is contained in:
parent
b646c2fd98
commit
2be4080bc6
@ -1,7 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import distutils.dir_util
|
import functools
|
||||||
import shutil
|
import shutil
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -127,15 +127,13 @@ class Installable(RepoJSONMixin):
|
|||||||
if self._location.is_file():
|
if self._location.is_file():
|
||||||
copy_func = shutil.copy2
|
copy_func = shutil.copy2
|
||||||
else:
|
else:
|
||||||
# clear copy_tree's cache to make sure missing directories are created (GH-2690)
|
copy_func = functools.partial(shutil.copytree, dirs_exist_ok=True)
|
||||||
distutils.dir_util._path_created = {}
|
|
||||||
copy_func = distutils.dir_util.copy_tree
|
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
copy_func(src=str(self._location), dst=str(target_dir / self._location.stem))
|
copy_func(src=str(self._location), dst=str(target_dir / self._location.stem))
|
||||||
except: # noqa: E722
|
except: # noqa: E722
|
||||||
log.exception("Error occurred when copying path: {}".format(self._location))
|
log.exception("Error occurred when copying path: %s", self._location)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user