]> git.phdru.name Git - phdru.name/cgi-bin/blog-ru/search-tags.git/blob - tags.py
Process single tag
[phdru.name/cgi-bin/blog-ru/search-tags.git] / tags.py
1 blog_filename = "blog_dict.pickle"
2
3 try:
4    import cPickle as pickle
5 except ImportError:
6    import pickle
7
8 try:
9    blog_file = open(blog_filename, "rb")
10 except IOError:
11    blog_dict = {}
12 else:
13    blog_dict = pickle.load(blog_file)
14    blog_file.close()
15
16
17 # blog_dict is a mapping
18 # (year, month, day) => [list of (file, title, lead, tags)]
19
20 def tag_exists(tag):
21     for posts in blog_dict.itervalues():
22         for _file, _title, _lead, tags in posts:
23             if tag in tags:
24                 return True
25     return False