1086 makedirs(parent, mode, notindexed) |
1086 makedirs(parent, mode, notindexed) |
1087 makedir(name, notindexed) |
1087 makedir(name, notindexed) |
1088 if mode is not None: |
1088 if mode is not None: |
1089 os.chmod(name, mode) |
1089 os.chmod(name, mode) |
1090 |
1090 |
1091 def ensuredirs(name, mode=None): |
1091 def ensuredirs(name, mode=None, notindexed=False): |
1092 """race-safe recursive directory creation""" |
1092 """race-safe recursive directory creation |
|
1093 |
|
1094 Newly created directories are marked as "not to be indexed by |
|
1095 the content indexing service", if ``notindexed`` is specified |
|
1096 for "write" mode access. |
|
1097 """ |
1093 if os.path.isdir(name): |
1098 if os.path.isdir(name): |
1094 return |
1099 return |
1095 parent = os.path.dirname(os.path.abspath(name)) |
1100 parent = os.path.dirname(os.path.abspath(name)) |
1096 if parent != name: |
1101 if parent != name: |
1097 ensuredirs(parent, mode) |
1102 ensuredirs(parent, mode, notindexed) |
1098 try: |
1103 try: |
1099 os.mkdir(name) |
1104 makedir(name, notindexed) |
1100 except OSError, err: |
1105 except OSError, err: |
1101 if err.errno == errno.EEXIST and os.path.isdir(name): |
1106 if err.errno == errno.EEXIST and os.path.isdir(name): |
1102 # someone else seems to have won a directory creation race |
1107 # someone else seems to have won a directory creation race |
1103 return |
1108 return |
1104 raise |
1109 raise |