Show More
@@ -1195,24 +1195,7 def opener(base, audit=True): | |||
|
1195 | 1195 | except: pass |
|
1196 | 1196 | posixfile.close(self) |
|
1197 | 1197 | |
|
1198 | class atomicfile(atomictempfile): | |
|
1199 | """the file will only be copied on close""" | |
|
1200 | def __init__(self, name, mode): | |
|
1201 | self._err = False | |
|
1202 | atomictempfile.__init__(self, name, mode) | |
|
1203 | def write(self, s): | |
|
1204 | try: | |
|
1205 | atomictempfile.write(self, s) | |
|
1206 | except: | |
|
1207 | self._err = True | |
|
1208 | raise | |
|
1209 | def close(self): | |
|
1210 | self.rename() | |
|
1211 | def __del__(self): | |
|
1212 | if not self._err: | |
|
1213 | self.rename() | |
|
1214 | ||
|
1215 | def o(path, mode="r", text=False, atomic=False, atomictemp=False): | |
|
1198 | def o(path, mode="r", text=False, atomictemp=False): | |
|
1216 | 1199 | if audit_p: |
|
1217 | 1200 | audit_path(path) |
|
1218 | 1201 | f = os.path.join(p, path) |
@@ -1228,9 +1211,7 def opener(base, audit=True): | |||
|
1228 | 1211 | d = os.path.dirname(f) |
|
1229 | 1212 | if not os.path.isdir(d): |
|
1230 | 1213 | os.makedirs(d) |
|
1231 | if atomic: | |
|
1232 | return atomicfile(f, mode) | |
|
1233 | elif atomictemp: | |
|
1214 | if atomictemp: | |
|
1234 | 1215 | return atomictempfile(f, mode) |
|
1235 | 1216 | if nlink > 1: |
|
1236 | 1217 | rename(mktempcopy(f), f) |
General Comments 0
You need to be logged in to leave comments.
Login now