Change venv

This commit is contained in:
Ambulance Clerc
2023-05-31 08:31:22 +02:00
parent fb6f579089
commit fdbb52c96f
466 changed files with 25899 additions and 64721 deletions

View File

@@ -8,12 +8,10 @@ from distutils.errors import DistutilsFileError
from distutils import log
# for generating verbose output in 'copy_file()'
_copy_action = { None: 'copying',
'hard': 'hard linking',
'sym': 'symbolically linking' }
_copy_action = {None: 'copying', 'hard': 'hard linking', 'sym': 'symbolically linking'}
def _copy_file_contents(src, dst, buffer_size=16*1024):
def _copy_file_contents(src, dst, buffer_size=16 * 1024): # noqa: C901
"""Copy the file 'src' to 'dst'; both must be filenames. Any error
opening either file, reading from 'src', or writing to 'dst', raises
DistutilsFileError. Data is read/written in chunks of 'buffer_size'
@@ -28,27 +26,30 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
try:
fsrc = open(src, 'rb')
except OSError as e:
raise DistutilsFileError("could not open '%s': %s" % (src, e.strerror))
raise DistutilsFileError("could not open '{}': {}".format(src, e.strerror))
if os.path.exists(dst):
try:
os.unlink(dst)
except OSError as e:
raise DistutilsFileError(
"could not delete '%s': %s" % (dst, e.strerror))
"could not delete '{}': {}".format(dst, e.strerror)
)
try:
fdst = open(dst, 'wb')
except OSError as e:
raise DistutilsFileError(
"could not create '%s': %s" % (dst, e.strerror))
"could not create '{}': {}".format(dst, e.strerror)
)
while True:
try:
buf = fsrc.read(buffer_size)
except OSError as e:
raise DistutilsFileError(
"could not read from '%s': %s" % (src, e.strerror))
"could not read from '{}': {}".format(src, e.strerror)
)
if not buf:
break
@@ -57,15 +58,25 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
fdst.write(buf)
except OSError as e:
raise DistutilsFileError(
"could not write to '%s': %s" % (dst, e.strerror))
"could not write to '{}': {}".format(dst, e.strerror)
)
finally:
if fdst:
fdst.close()
if fsrc:
fsrc.close()
def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
link=None, verbose=1, dry_run=0):
def copy_file( # noqa: C901
src,
dst,
preserve_mode=1,
preserve_times=1,
update=0,
link=None,
verbose=1,
dry_run=0,
):
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
copied there with the same name; otherwise, it must be a filename. (If
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
@@ -102,7 +113,8 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
if not os.path.isfile(src):
raise DistutilsFileError(
"can't copy '%s': doesn't exist or not a regular file" % src)
"can't copy '%s': doesn't exist or not a regular file" % src
)
if os.path.isdir(dst):
dir = dst
@@ -163,9 +175,7 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
# XXX I suspect this is Unix-specific -- need porting help!
def move_file (src, dst,
verbose=1,
dry_run=0):
def move_file(src, dst, verbose=1, dry_run=0): # noqa: C901
"""Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
be moved into it with the same name; otherwise, 'src' is just renamed
@@ -190,13 +200,13 @@ def move_file (src, dst,
dst = os.path.join(dst, basename(src))
elif exists(dst):
raise DistutilsFileError(
"can't move '%s': destination '%s' already exists" %
(src, dst))
"can't move '{}': destination '{}' already exists".format(src, dst)
)
if not isdir(dirname(dst)):
raise DistutilsFileError(
"can't move '%s': destination '%s' not a valid path" %
(src, dst))
"can't move '{}': destination '{}' not a valid path".format(src, dst)
)
copy_it = False
try:
@@ -207,7 +217,8 @@ def move_file (src, dst,
copy_it = True
else:
raise DistutilsFileError(
"couldn't move '%s' to '%s': %s" % (src, dst, msg))
"couldn't move '{}' to '{}': {}".format(src, dst, msg)
)
if copy_it:
copy_file(src, dst, verbose=verbose)
@@ -220,13 +231,13 @@ def move_file (src, dst,
except OSError:
pass
raise DistutilsFileError(
"couldn't move '%s' to '%s' by copy/delete: "
"delete '%s' failed: %s"
% (src, dst, src, msg))
"couldn't move '%s' to '%s' by copy/delete: "
"delete '%s' failed: %s" % (src, dst, src, msg)
)
return dst
def write_file (filename, contents):
def write_file(filename, contents):
"""Create a file with the specified name and write 'contents' (a
sequence of strings without line terminators) to it.
"""