Create a file in the tmp subdirectory and open and return it.
(self)
| 488 | _count = 1 # This is used to generate unique file names. |
| 489 | |
| 490 | def _create_tmp(self): |
| 491 | """Create a file in the tmp subdirectory and open and return it.""" |
| 492 | now = time.time() |
| 493 | hostname = socket.gethostname() |
| 494 | if '/' in hostname: |
| 495 | hostname = hostname.replace('/', r'\057') |
| 496 | if ':' in hostname: |
| 497 | hostname = hostname.replace(':', r'\072') |
| 498 | uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(), |
| 499 | Maildir._count, hostname) |
| 500 | path = os.path.join(self._path, 'tmp', uniq) |
| 501 | try: |
| 502 | os.stat(path) |
| 503 | except FileNotFoundError: |
| 504 | Maildir._count += 1 |
| 505 | try: |
| 506 | return _create_carefully(path) |
| 507 | except FileExistsError: |
| 508 | pass |
| 509 | |
| 510 | # Fall through to here if stat succeeded or open raised EEXIST. |
| 511 | raise ExternalClashError('Name clash prevented file creation: %s' % |
| 512 | path) |
| 513 | |
| 514 | def _refresh(self): |
| 515 | """Update table of contents mapping.""" |
no test coverage detected