Creates a temporary working directory with the specified path name. If the path is a null string (''), a unique directory name is created.
(self, path)
| 504 | self.verbose = verbose |
| 505 | |
| 506 | def workdir_set(self, path): |
| 507 | """ |
| 508 | Creates a temporary working directory with the specified path name. |
| 509 | If the path is a null string (''), a unique directory name is created. |
| 510 | |
| 511 | """ |
| 512 | if os.path.isabs(path): |
| 513 | self.workdir = path |
| 514 | else: |
| 515 | if path != None: |
| 516 | if path == '': |
| 517 | path = tempfile.mktemp() |
| 518 | if path != None: |
| 519 | os.mkdir(path) |
| 520 | self._dirlist.append(path) |
| 521 | global _Cleanup |
| 522 | try: |
| 523 | _Cleanup.index(self) |
| 524 | except ValueError: |
| 525 | _Cleanup.append(self) |
| 526 | # We would like to set self.workdir like this: |
| 527 | # self.workdir = path |
| 528 | # But symlinks in the path will report things differently from |
| 529 | # os.getcwd(), so chdir there and back to fetch the canonical |
| 530 | # path. |
| 531 | cwd = os.getcwd() |
| 532 | os.chdir(path) |
| 533 | self.workdir = os.getcwd() |
| 534 | os.chdir(cwd) |
| 535 | else: |
| 536 | self.workdir = None |
| 537 | |
| 538 | def workpath(self, *args): |
| 539 | """ |