def find_new_posts_and_pages(db):
Q = Query()<EOL>for root, dirs, files in os.walk(CONFIG['<STR_LIT>']):<EOL><INDENT>for filename in sorted([f for f in files if<EOL>f.endswith(('<STR_LIT>', '<STR_LIT>'))]):<EOL><INDENT>fullpath = os.path.join(root, filename)<EOL>_p = fullpath.split(CONFIG['<STR_LIT>'])[-<NUM_LIT:1>].lstrip('<STR_LIT:/>')<EOL>new_mtime = int(os.path.getmtime(fullpath))<EOL>e, item = None, None<EOL>for collection in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>item = db[collection].get(Q.filename == _p)<EOL>if item:<EOL><INDENT>if new_mtime > item['<STR_LIT>']:<EOL><INDENT>db[collection].update({'<STR_LIT>': new_mtime},<EOL>doc_ids=[item.doc_id])<EOL>e = Entry(fullpath, doc_id=item.doc_id)<EOL><DEDENT>break<EOL><DEDENT><DEDENT>if not item:<EOL><INDENT>e = Entry(fullpath)<EOL><DEDENT>if e:<EOL><INDENT>yield e, e.id<EOL><DEDENT><DEDENT><DEDENT>
Walk content dir, put each post and page in the database