| LEFT | RIGHT |
| 1 """Utility functions for copying files and directory trees. | 1 """Utility functions for copying files and directory trees. |
| 2 | 2 |
| 3 XXX The functions here don't copy the resource fork or other metadata on Mac. | 3 XXX The functions here don't copy the resource fork or other metadata on Mac. |
| 4 | 4 |
| 5 """ | 5 """ |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import stat | 9 import stat |
| 10 from os.path import abspath | 10 from os.path import abspath |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 # XXX What about devices, sockets etc.? | 130 # XXX What about devices, sockets etc.? |
| 131 except (IOError, os.error), why: | 131 except (IOError, os.error), why: |
| 132 errors.append((srcname, dstname, str(why))) | 132 errors.append((srcname, dstname, str(why))) |
| 133 # catch the Error from the recursive copytree so that we can | 133 # catch the Error from the recursive copytree so that we can |
| 134 # continue with other files | 134 # continue with other files |
| 135 except Error, err: | 135 except Error, err: |
| 136 errors.extend(err.args[0]) | 136 errors.extend(err.args[0]) |
| 137 try: | 137 try: |
| 138 copystat(src, dst) | 138 copystat(src, dst) |
| 139 except OSError, why: | 139 except OSError, why: |
| 140 if WindowsError is not None and isinstance(err, WindowsError): | 140 if WindowsError is not None and isinstance(why, WindowsError): |
| 141 # Copying file access times may fail on Windows | 141 # Copying file access times may fail on Windows |
| 142 pass | 142 pass |
| 143 else: | 143 else: |
| 144 errors.extend((src, dst, str(why))) | 144 errors.extend((src, dst, str(why))) |
| 145 if errors: | 145 if errors: |
| 146 raise Error, errors | 146 raise Error, errors |
| 147 | 147 |
| 148 def rmtree(path, ignore_errors=False, onerror=None): | 148 def rmtree(path, ignore_errors=False, onerror=None): |
| 149 """Recursively delete a directory tree. | 149 """Recursively delete a directory tree. |
| 150 | 150 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if destinsrc(src, dst): | 228 if destinsrc(src, dst): |
| 229 raise Error, "Cannot move a directory '%s' into itself '%s'." %
(src, dst) | 229 raise Error, "Cannot move a directory '%s' into itself '%s'." %
(src, dst) |
| 230 copytree(src, real_dst, symlinks=True) | 230 copytree(src, real_dst, symlinks=True) |
| 231 rmtree(src) | 231 rmtree(src) |
| 232 else: | 232 else: |
| 233 copy2(src, real_dst) | 233 copy2(src, real_dst) |
| 234 os.unlink(src) | 234 os.unlink(src) |
| 235 | 235 |
| 236 def destinsrc(src, dst): | 236 def destinsrc(src, dst): |
| 237 return abspath(dst).startswith(abspath(src)) | 237 return abspath(dst).startswith(abspath(src)) |
| LEFT | RIGHT |