import os import markdown from random import choice # Get the directory path of the script script_dir = os.path.dirname(os.path.abspath(__file__)) materials = ['1_situation', '2_binding', '3_paperformat', '4_add_ons'] cards = { '1_situation' : { 'content' : [], 'make-a-notebook-that' : [] }, '2_binding' : { 'content' : [], 'make-a-notebook-that' : [] }, '3_paperformat' : { 'content' : [], 'make-a-notebook-that' : [] }, '4_add_ons' : { 'content' : [], 'make-a-notebook-that' : [] } } for folder in materials: material_folder_path = os.path.join(script_dir, folder) card_folders = os.listdir(material_folder_path) #print(material_folder_path) for card_folder in card_folders: card_folder_path = os.path.join(material_folder_path, card_folder) #print(card_folder_path) #these are content and make a notebook that folders paths my_files = os.listdir(card_folder_path) #print(my_files) for my_file in my_files: file_path = os.path.join(card_folder_path, my_file) relative_file_path = os.path.relpath(file_path, os.path.dirname(__file__)) #image_path = #print(file_path) #print(relative_file_path) if my_file.endswith(('.md', '.markdown')): with open(file_path, 'r') as file: md = file.read() card = markdown.markdown(md) #print(card) # the print of all the md files cards[folder][card_folder].append(card) elif my_file.endswith(('.jpg', '.jpeg', '.png')): if 'prototype_' in my_file: my_file= my_file.replace('.jpg', '').replace('.jpeg', '').replace('.png', '').replace('prototype_', '').replace('_', ' ') image_html = f'' + f"