diff options
author | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2023-02-20 15:42:33 +0000 |
---|---|---|
committer | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2023-02-21 15:52:39 +0000 |
commit | 803a91c0723533f62148528a81f9d0411b57438e (patch) | |
tree | 953b9bd41aa86edf030e009758280d46b8556fe6 /src/mlia/utils | |
parent | a01e0e1229e30f9e2ebf3cd921ffe0dbef1cbea9 (diff) | |
download | mlia-803a91c0723533f62148528a81f9d0411b57438e.tar.gz |
MLIA-813 Change default output directory0.6.0-rc.30.6.0
- Use directory mlia-output as output directory for MLIA
- If parameter --output-dir provided then place directory
mlia-output under specified path or otherwise create it
in the current working directory
Change-Id: I298088c4aa8dbe9f35dee69ecb9ff6e9ea3cac0a
Diffstat (limited to 'src/mlia/utils')
-rw-r--r-- | src/mlia/utils/filesystem.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mlia/utils/filesystem.py b/src/mlia/utils/filesystem.py index f92629b..f8e8962 100644 --- a/src/mlia/utils/filesystem.py +++ b/src/mlia/utils/filesystem.py @@ -14,6 +14,8 @@ from tempfile import TemporaryDirectory from typing import Generator from typing import Iterable +USER_ONLY_PERM_MASK = 0o700 + def get_mlia_resources() -> Path: """Get the path to the resources directory.""" @@ -96,6 +98,17 @@ def copy_all(*paths: Path, dest: Path) -> None: shutil.copytree(path, dest, dirs_exist_ok=True) +def recreate_directory(dir_path: Path, mode: int = USER_ONLY_PERM_MASK) -> None: + """Recreate directory.""" + if dir_path.exists(): + if not dir_path.is_dir(): + raise ValueError(f"Path {dir_path} is not a directory.") + + shutil.rmtree(dir_path) + + dir_path.mkdir(exist_ok=True, mode=mode) + + @contextmanager def working_directory( working_dir: Path, create_dir: bool = False |