MCPcopy Index your code
hub / github.com/python/cpython / copymode

Function copymode

Lib/shutil.py:355–379  ·  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

353 return dst
354
355def copymode(src, dst, *, follow_symlinks=True):
356 """Copy mode bits from src to dst.
357
358 If follow_symlinks is not set, symlinks aren't followed if and only
359 if both `src` and `dst` are symlinks. If `lchmod` isn't available
360 (e.g. Linux) this method does nothing.
361
362 """
363 sys.audit("shutil.copymode", src, dst)
364
365 if not follow_symlinks and _islink(src) and os.path.islink(dst):
366 if hasattr(os, 'lchmod'):
367 stat_func, chmod_func = os.lstat, os.lchmod
368 else:
369 return
370 else:
371 stat_func = _stat
372 if os.name == 'nt' and os.path.islink(dst):
373 def chmod_func(*args):
374 os.chmod(*args, follow_symlinks=True)
375 else:
376 chmod_func = os.chmod
377
378 st = stat_func(src)
379 chmod_func(dst, stat.S_IMODE(st.st_mode))
380
381if hasattr(os, 'listxattr'):
382 def _copyxattr(src, dst, *, follow_symlinks=True):

Callers 1

copyFunction · 0.85

Calls 3

_islinkFunction · 0.85
chmod_funcFunction · 0.85
islinkMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…