Make the specified directory tree writable (write == 1) or not (write == None).
(self, top, write)
| 545 | return apply(os.path.join, (self.workdir,) + tuple(args)) |
| 546 | |
| 547 | def writable(self, top, write): |
| 548 | """ |
| 549 | Make the specified directory tree writable (write == 1) or not |
| 550 | (write == None). |
| 551 | |
| 552 | """ |
| 553 | def _walk_chmod(arg, dirname, names): |
| 554 | st = os.stat(dirname) |
| 555 | os.chmod(dirname, arg(st[stat.ST_MODE])) |
| 556 | for name in names: |
| 557 | fullname = os.path.join(dirname, name) |
| 558 | st = os.stat(fullname) |
| 559 | os.chmod(fullname, arg(st[stat.ST_MODE])) |
| 560 | |
| 561 | _mode_writable = lambda mode: stat.S_IMODE(mode|0200) |
| 562 | _mode_non_writable = lambda mode: stat.S_IMODE(mode&~0200) |
| 563 | |
| 564 | if write: |
| 565 | f = _mode_writable |
| 566 | else: |
| 567 | f = _mode_non_writable |
| 568 | try: |
| 569 | os.path.walk(top, _walk_chmod, f) |
| 570 | except: |
| 571 | pass # Ignore any problems changing modes. |
| 572 | |
| 573 | def write(self, file, content, mode='wb'): |
| 574 | """ |