MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / copymode

Function copymode

tools/python-3.11.9-amd64/Lib/shutil.py:290–313  ·  view source on GitHub ↗

Copy mode bits from src to dst. If follow_symlinks is not set, symlinks aren't followed if and only if both `src` and `dst` are symlinks. If `lchmod` isn't available (e.g. Linux) this method does nothing.

(src, dst, *, follow_symlinks=True)

Source from the content-addressed store, hash-verified

288 return dst
289
290def copymode(src, dst, *, follow_symlinks=True):
291 """Copy mode bits from src to dst.
292
293 If follow_symlinks is not set, symlinks aren't followed if and only
294 if both `src` and `dst` are symlinks. If `lchmod` isn't available
295 (e.g. Linux) this method does nothing.
296
297 """
298 sys.audit("shutil.copymode", src, dst)
299
300 if not follow_symlinks and _islink(src) and os.path.islink(dst):
301 if os.name == 'nt':
302 stat_func, chmod_func = os.lstat, os.chmod
303 elif hasattr(os, 'lchmod'):
304 stat_func, chmod_func = os.lstat, os.lchmod
305 else:
306 return
307 else:
308 if os.name == 'nt' and os.path.islink(dst):
309 dst = os.path.realpath(dst, strict=True)
310 stat_func, chmod_func = _stat, os.chmod
311
312 st = stat_func(src)
313 chmod_func(dst, stat.S_IMODE(st.st_mode))
314
315if hasattr(os, 'listxattr'):
316 def _copyxattr(src, dst, *, follow_symlinks=True):

Callers 1

copyFunction · 0.85

Calls 2

_islinkFunction · 0.85
realpathMethod · 0.80

Tested by

no test coverage detected