Tries to find a directory in `workdir` which name is an integer and return a large integer padded. The returned name is padded by zeros.
(workdir: Path)
| 3 | |
| 4 | |
| 5 | def generate_job_dir(workdir: Path) -> Path: |
| 6 | """Tries to find a directory in `workdir` which name is an integer and return a large integer |
| 7 | padded. The returned name is padded by zeros.""" |
| 8 | workdir.mkdir(parents=True, exist_ok=True) |
| 9 | |
| 10 | ids = [] |
| 11 | for item in workdir.iterdir(): |
| 12 | if item.is_dir(): |
| 13 | try: |
| 14 | ids.append(int(item.name)) |
| 15 | except BaseException: |
| 16 | pass |
| 17 | max_id = max(ids or [0]) |
| 18 | dir_name = f"{max_id + 1:03}" |
| 19 | return (workdir / dir_name).absolute() |
| 20 | |
| 21 | |
| 22 | def format_allocation_time(duration: datetime.timedelta) -> str: |
no test coverage detected