def nb_to_md(src_dir, nb_folder, dest_dir): notebooks_dir = src_dir / nb_folder logger.opt(colors=True).log( "INFO", "️<green><bold>Notebooks folder: {}</></>", notebooks_dir, ) for file_path in os.listdir(notebooks_dir): dir_path = notebooks_dir file_name = file_path nb_path = os.path.join(dir_path, file_path) file_name_no_ext = os.path.splitext(file_name)[0] ext = os.path.splitext(file_name)[1] if ext != ".ipynb": continue # md_path = os.path.join(dest_dir, 'tutorial', file_name_no_ext + '.md') file_name_md = file_name_no_ext + ".md" # md_path = os.path.join(dest_dir, file_name_md) md_path = os.path.join(dest_dir, file_name_no_ext + ".md") images_path = "images" tutobooks.nb_to_md(nb_path, md_path, images_path) from_to = f"{file_name} -> {file_name_md}" logger.opt(colors=True).log( "INFO", "️<green><bold>Converting to Notebook: {}</></>", from_to, )
def nb_to_md(src_dir, nb_folder, dest_dir): notebooks_dir = src_dir / nb_folder print("Notebooks folder: ", notebooks_dir) for file_path in os.listdir(notebooks_dir): dir_path = notebooks_dir file_name = file_path nb_path = os.path.join(dir_path, file_path) file_name_no_ext = os.path.splitext(file_name)[0] ext = os.path.splitext(file_name)[1] if ext != ".ipynb": continue # md_path = os.path.join(dest_dir, 'tutorial', file_name_no_ext + '.md') md_path = os.path.join(dest_dir, file_name_no_ext + ".md") images_path = "images" tutobooks.nb_to_md(nb_path, md_path, images_path)