Show More
@@ -1260,6 +1260,12 b' class opener(object):' | |||||
1260 | self.base = base |
|
1260 | self.base = base | |
1261 | self.audit = audit |
|
1261 | self.audit = audit | |
1262 |
|
1262 | |||
|
1263 | def __getattr__(self, name): | |||
|
1264 | if name == '_can_symlink': | |||
|
1265 | self._can_symlink = checklink(self.base) | |||
|
1266 | return self._can_symlink | |||
|
1267 | raise AttributeError(name) | |||
|
1268 | ||||
1263 | def __call__(self, path, mode="r", text=False, atomictemp=False): |
|
1269 | def __call__(self, path, mode="r", text=False, atomictemp=False): | |
1264 | if self.audit: |
|
1270 | if self.audit: | |
1265 | audit_path(path) |
|
1271 | audit_path(path) | |
@@ -1282,6 +1288,26 b' class opener(object):' | |||||
1282 | rename(mktempcopy(f), f) |
|
1288 | rename(mktempcopy(f), f) | |
1283 | return posixfile(f, mode) |
|
1289 | return posixfile(f, mode) | |
1284 |
|
1290 | |||
|
1291 | def symlink(self, src, dst): | |||
|
1292 | if self.audit: | |||
|
1293 | audit_path(dst) | |||
|
1294 | linkname = os.path.join(self.base, dst) | |||
|
1295 | try: | |||
|
1296 | os.unlink(linkname) | |||
|
1297 | except OSError: | |||
|
1298 | pass | |||
|
1299 | ||||
|
1300 | dirname = os.path.dirname(linkname) | |||
|
1301 | if not os.path.exists(dirname): | |||
|
1302 | os.makedirs(dirname) | |||
|
1303 | ||||
|
1304 | if self._can_symlink: | |||
|
1305 | os.symlink(src, linkname) | |||
|
1306 | else: | |||
|
1307 | f = self(self, dst, "w") | |||
|
1308 | f.write(src) | |||
|
1309 | f.close() | |||
|
1310 | ||||
1285 | class chunkbuffer(object): |
|
1311 | class chunkbuffer(object): | |
1286 | """Allow arbitrary sized chunks of data to be efficiently read from an |
|
1312 | """Allow arbitrary sized chunks of data to be efficiently read from an | |
1287 | iterator over chunks of arbitrary size.""" |
|
1313 | iterator over chunks of arbitrary size.""" |
General Comments 0
You need to be logged in to leave comments.
Login now