diff --git a/django/core/management/base.py b/django/core/management/base.py
index 6b9ce6e..a509d6f 100644
a
|
b
|
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
370 | 370 | # other_name -- When copying an application layout, this should be the name |
371 | 371 | # of the project. |
372 | 372 | import re |
373 | | import shutil |
374 | 373 | other = {'project': 'app', 'app': 'project'}[app_or_project] |
375 | 374 | if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name. |
376 | 375 | # Provide a smart error message, depending on the error. |
… |
… |
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
410 | 409 | fp_old.close() |
411 | 410 | fp_new.close() |
412 | 411 | try: |
413 | | shutil.copymode(path_old, path_new) |
| 412 | _copy_execute_permission(path_old, path_new) |
414 | 413 | _make_writeable(path_new) |
415 | 414 | except OSError: |
416 | 415 | sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new)) |
417 | 416 | |
| 417 | def _copy_execute_permission(path_old, path_new): |
| 418 | """ |
| 419 | Copy files respecting the user's umask if supported by the OS |
| 420 | |
| 421 | """ |
| 422 | import stat |
| 423 | if hasattr(os, 'chmod'): |
| 424 | st = os.stat(path_old) |
| 425 | mode = stat.S_IMODE(st.st_mode) |
| 426 | if mode & 0111: |
| 427 | new_mode = stat.S_IMODE(os.stat(path_new).st_mode) |
| 428 | os.chmod(path_new, new_mode | 0111) |
| 429 | |
418 | 430 | def _make_writeable(filename): |
419 | 431 | """ |
420 | 432 | Make sure that the file is writeable. Useful if our source is |