import pathlib


def get_abs_filename_with_sub_path(sub_path, filename):

    """
        生成当前路径下一级路径某文件的完整文件名；

        :param:
            * sub_path: (string) 下一级的某路径名称
            * filename: (string) 下一级路径的某个文件名
        :returns:
            * 返回类型 (tuple)，有两个值，第一个为 flag，第二个为文件名，说明见下
            * flag: (bool) 如果文件存在，返回 True，文件不存在，返回 False
            * abs_filename: (string) 指定 filename 的包含路径的长文件名

        举例如下::
            
            print('--- get_abs_filename_with_sub_path demo ---')
            # define sub dir
            path_name = 'sub_dir'
            # define not exists file
            filename = 'test_file.txt'

            abs_filename = get_abs_filename_with_sub_path(path_name, filename)
            # return False and abs filename
            print(abs_filename)

            # define exists file
            filename = 'demo.txt'
            abs_filename = get_abs_filename_with_sub_path(path_name, filename)
            # return True and abs filename
            print(abs_filename)
            print('---')

        输出结果::
            
            --- get_abs_filename_with_sub_path demo ---
            (False, '/Users/****/Documents/dev_python/fishbase/demo/sub_dir/test_file.txt')
            (True, '/Users/****/Documents/dev_python/fishbase/demo/sub_dir/demo.txt')
            ---
            
    """

    try:
        cur_path = pathlib.Path.cwd()
        abs_filename = cur_path / pathlib.Path(sub_path) / filename
        flag = pathlib.Path.is_file(abs_filename)

        # 将 path 对象转换成字符串
        return flag, str(abs_filename)

    except:

        flag = False
        return flag, None