This repository has been archived on 2023-11-11. You can view files and clone it, but cannot push or open issues or pull requests.
automated-youtube-dl/ydl/files.py

20 lines
454 B
Python

import tempfile
from pathlib import Path
from typing import Union
def create_directories(*paths: Union[str, Path]):
for path in paths:
resolve_path(path).mkdir(parents=True, exist_ok=True)
def mktemp(directory=True) -> Path:
if directory:
return Path(tempfile.mkdtemp())
else:
return Path(tempfile.mkstemp()[1])
def resolve_path(p: Union[str, Path]) -> Path:
return Path(p).expanduser().absolute().resolve()