File: strip_cookbook_data.py

package info (click to toggle)
python-markdown2 2.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,492 kB
  • sloc: python: 6,201; perl: 1,493; php: 865; makefile: 37
file content (21 lines) | stat: -rw-r--r-- 536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from os.path import *
from pprint import pformat

def doit():
    recipes_path = expanduser("recipes.pprint")
    recipe_dicts = eval(open(recipes_path).read())
    for r in recipe_dicts:
        for key in r.keys():
            if key not in ('desc', 'comments'):
                del r[key]
        for c in r['comments']:
            for key in c.keys():
                if key not in ('comment', 'title'):
                    del c[key]

    f = open("stripped.pprint", 'w')
    f.write(pformat(recipe_dicts))
    f.close()


doit()