Skip to content

Commit

Permalink
Add: Add check.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
chairc committed Apr 15, 2024
1 parent cae695e commit 4a35333
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
10 changes: 0 additions & 10 deletions tools/__init__.py

This file was deleted.

35 changes: 35 additions & 0 deletions utils/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@Date : 2024/4/14 17:31
@Author : chairc
@Site : https://github.com/chairc
"""
import os
import logging
import coloredlogs

import torch

logger = logging.getLogger(__name__)
coloredlogs.install(level="INFO")


def check_and_create_dir(path):
"""
Check and create not exist folder
:param path: Create path
:return: None
"""
logger.info(msg=f"Check and create folder '{path}'.")
os.makedirs(name=path, exist_ok=True)


def check_path_is_exist(path):
"""
Check the path is existed
:param path: Path
:return: None
"""
if not os.path.exists(path=path):
raise FileNotFoundError(f"The path '{path}' does not exist.")

0 comments on commit 4a35333

Please sign in to comment.