diff options
author | Bruno Haible <bruno@clisp.org> | 2022-08-03 11:27:21 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-08-03 11:27:21 +0200 |
commit | dbc9a4b304185e2cb0d9f425866f71161c9a1255 (patch) | |
tree | 3ea1526794114be5ee54c00ed8305f18fc969e6f /pygnulib/constants.py | |
parent | f88aeeb42a4926bc2f7bcb7758ca511e75404593 (diff) | |
download | gnulib-dbc9a4b304185e2cb0d9f425866f71161c9a1255.tar.gz |
gnulib-tool.py: Avoid errors when writing to a VFAT file system.
* pygnulib/constants.py (copyfile, copyfile2): New functions.
* gnulib-tool.py: Use them instead of shutil.
* pygnulib/*.py: Likewise.
Diffstat (limited to 'pygnulib/constants.py')
-rw-r--r-- | pygnulib/constants.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 91a2958eb3..cf6f05eb98 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -23,6 +23,7 @@ import re import os import sys import platform +import shutil import tempfile import subprocess as sp import __main__ as interpreter @@ -303,6 +304,27 @@ def relconcat(dir1, dir2): return os.path.normpath(os.path.join(dir1, dir2)) +def copyfile(src, dest): + '''Copy file src to file dest. Like shutil.copy, but ignore errors e.g. on + VFAT file systems.''' + shutil.copyfile(src, dest) + try: + shutil.copymode(src, dest) + except PermissionError: + pass + + +def copyfile2(src, dest): + '''Copy file src to file dest, preserving modification time. Like + shutil.copy2, but ignore errors e.g. on VFAT file systems. This function + is to be used for backup files.''' + shutil.copyfile(src, dest) + try: + shutil.copystat(src, dest) + except PermissionError: + pass + + def link_relative(src, dest): '''Like ln -s, except that src is given relative to the current directory (or absolute), not given relative to the directory of dest.''' |