from datetime import date


def make_dir(parent_path, *dir_name, add_date=True):
    """
    Make a new directory
    Parameters
    ----------
    parent_path : str
    dir_name : str
         (optional), if not exists, files will be saved in parent_dir
    add_date : bool
        make a sub-dir with a date

    Returns
    -------
    save_path : path
    """

    global save_path
    if dir_name:
        if add_date:
            today = date.today()
            save_path = parent_path / dir_name[0] / today.strftime("%Y-%m-%d")  # 2020-07-04
        else:
            save_path = parent_path / dir_name[0]
    else:
        if add_date:
            today = date.today()
            save_path = parent_path / today.strftime("%Y-%m-%d")  # 2020-07-04
        else:
            save_path = parent_path

    # print(save_path)
    if not save_path.exists():
        save_path.mkdir(parents=True)
    return save_path