# 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")
[((10, 30, 10, 53), 'os.walk', 'walk', ({(10, 35, 10, 52): 'categories_folder'}, {}), '(categories_folder)', False, 'from os import walk\n'), ((16, 30, 16, 47), 'os.walk', 'walk', ({(16, 35, 16, 46): 'post_folder'}, {}), '(post_folder)', False, 'from os import walk\n'), ((6, 28, 6, 67), 'os.path.join', 'join', ({(6, 33, 6, 41): '__file__', (6, 42, 6, 48): 'pardir', (6, 49, 6, 55): 'pardir', (6, 56, 6, 66): '"""category"""'}, {}), "(__file__, pardir, pardir, 'category')", False, 'from os.path import abspath, join, pardir\n'), ((7, 22, 7, 59), 'os.path.join', 'join', ({(7, 27, 7, 35): '__file__', (7, 36, 7, 42): 'pardir', (7, 43, 7, 49): 'pardir', (7, 50, 7, 58): '"""_posts"""'}, {}), "(__file__, pardir, pardir, '_posts')", False, 'from os.path import abspath, join, pardir\n'), ((18, 18, 18, 30), 'os.path.join', 'join', ({(18, 23, 18, 27): 'root', (18, 28, 18, 29): 'f'}, {}), '(root, f)', False, 'from os.path import abspath, join, pardir\n')]