Copy extended filesystem attributes from `src` to `dst`. Overwrite existing attributes. If `follow_symlinks` is false, symlinks won't be followed.
(src, dst, *, follow_symlinks=True)
| 314 | |
| 315 | if hasattr(os, 'listxattr'): |
| 316 | def _copyxattr(src, dst, *, follow_symlinks=True): |
| 317 | """Copy extended filesystem attributes from `src` to `dst`. |
| 318 | |
| 319 | Overwrite existing attributes. |
| 320 | |
| 321 | If `follow_symlinks` is false, symlinks won't be followed. |
| 322 | |
| 323 | """ |
| 324 | |
| 325 | try: |
| 326 | names = os.listxattr(src, follow_symlinks=follow_symlinks) |
| 327 | except OSError as e: |
| 328 | if e.errno not in (errno.ENOTSUP, errno.ENODATA, errno.EINVAL): |
| 329 | raise |
| 330 | return |
| 331 | for name in names: |
| 332 | try: |
| 333 | value = os.getxattr(src, name, follow_symlinks=follow_symlinks) |
| 334 | os.setxattr(dst, name, value, follow_symlinks=follow_symlinks) |
| 335 | except OSError as e: |
| 336 | if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA, |
| 337 | errno.EINVAL): |
| 338 | raise |
| 339 | else: |
| 340 | def _copyxattr(*args, **kwargs): |
| 341 | pass |