# list categories in category folder

from os import walk
from os.path import abspath,join, pardir

categories_folder = abspath(join(__file__,pardir,pardir,"category"))
post_folder = abspath(join(__file__,pardir,pardir,"_posts"))

site_categories = []
for root,directories,files in walk(categories_folder):
    for f in files:
        site_categories.append(f.split(".md")[0])
        
site_categories = set(site_categories)
        
for root,directories,files in walk(post_folder):
    for f in files:
        with open(join(root,f),'r',encoding="utf-8") as fi:
            lines = fi.readlines()
            for l in lines:
                if l.find("categories")==0:
                    categories = l.split(":")[1]
                    for c in [" ","[","]","\n"]:
                        categories = categories.replace(c,"")
                    categories=categories.split(",")
                    if len(set(categories)-site_categories)>0:
                        print(f,set(categories)-site_categories)
                    break
print("done")
[((282, 305), 'os.walk', 'walk', (['categories_folder'], {}), '(categories_folder)\n', (286, 305), False, 'from os import walk\n'), ((464, 481), 'os.walk', 'walk', (['post_folder'], {}), '(post_folder)\n', (468, 481), False, 'from os import walk\n'), ((128, 170), 'os.path.join', 'join', (['__file__', 'pardir', 'pardir', '"""category"""'], {}), "(__file__, pardir, pardir, 'category')\n", (132, 170), False, 'from os.path import abspath, join, pardir\n'), ((191, 231), 'os.path.join', 'join', (['__file__', 'pardir', 'pardir', '"""_posts"""'], {}), "(__file__, pardir, pardir, '_posts')\n", (195, 231), False, 'from os.path import abspath, join, pardir\n'), ((521, 534), 'os.path.join', 'join', (['root', 'f'], {}), '(root, f)\n', (525, 534), False, 'from os.path import abspath, join, pardir\n')]