Create new subdirectories under the temporary working directory, one for each argument. An argument may be a list, in which case the list elements are concatenated using the os.path.join() method. Subdirectories multiple levels deep must be created using a separate
(self, *subdirs)
| 458 | return self._stdout[run] |
| 459 | |
| 460 | def subdir(self, *subdirs): |
| 461 | """ |
| 462 | Create new subdirectories under the temporary working directory, one |
| 463 | for each argument. An argument may be a list, in which case the list |
| 464 | elements are concatenated using the os.path.join() method. |
| 465 | Subdirectories multiple levels deep must be created using a separate |
| 466 | argument for each level: |
| 467 | |
| 468 | test.subdir('sub', ['sub', 'dir'], ['sub', 'dir', 'ectory']) |
| 469 | |
| 470 | Returns the number of subdirectories actually created. |
| 471 | |
| 472 | """ |
| 473 | count = 0 |
| 474 | for sub in subdirs: |
| 475 | if sub is None: |
| 476 | continue |
| 477 | if type(sub) is ListType: |
| 478 | sub = apply(os.path.join, tuple(sub)) |
| 479 | new = os.path.join(self.workdir, sub) |
| 480 | try: |
| 481 | os.mkdir(new) |
| 482 | except: |
| 483 | pass |
| 484 | else: |
| 485 | count += 1 |
| 486 | return count |
| 487 | |
| 488 | def unlink(self, file): |
| 489 | """ |