(self, custom_path=None, keep_for_debug=None)
| 96 | cls._KEEP_FOR_DEBUG = old_keep_for_debug |
| 97 | |
| 98 | def __init__(self, custom_path=None, keep_for_debug=None): |
| 99 | if self.TEMPDIRS is None: |
| 100 | raise DirectoryCreatedPastAtExit() |
| 101 | |
| 102 | if keep_for_debug is not None: |
| 103 | self._created_with_keep_for_debug = keep_for_debug |
| 104 | else: |
| 105 | self._created_with_keep_for_debug = self._KEEP_FOR_DEBUG |
| 106 | |
| 107 | if custom_path: |
| 108 | os.mkdir(custom_path) |
| 109 | self.temp_dir = custom_path |
| 110 | else: |
| 111 | if self._created_with_keep_for_debug: |
| 112 | parent_dir = self._get_debug_parent_dir() |
| 113 | self.temp_dir = f"{parent_dir}/{self._increment_num_tempdir_created():05d}" |
| 114 | os.mkdir(self.temp_dir) |
| 115 | else: |
| 116 | self.temp_dir = tempfile.mkdtemp() |
| 117 | |
| 118 | if not self._created_with_keep_for_debug: |
| 119 | self.TEMPDIRS.add(self.temp_dir) |
| 120 | |
| 121 | def remove(self): |
| 122 | """Remove the tmp dir""" |
nothing calls this directly
no test coverage detected