X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=tags.py;h=e1d5dd11eaa625d321a49cff9bbe0249feaffefc;hb=61906da0870ec1610d64943fa0d7c054a9a1d2d4;hp=df64a1c286a7e645a84239c0d6571a7af46ee89d;hpb=6b692a173291f4f217d99e4f73281bd2b4d1fa1f;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/tags.py b/tags.py index df64a1c..e1d5dd1 100644 --- a/tags.py +++ b/tags.py @@ -6,7 +6,7 @@ except ImportError: import pickle try: - blog_file = open(blog_filename, "rb") + blog_file = open('../../../../phdru.name/ru/' + blog_filename, "rb") except IOError: blog_dict = {} else: @@ -25,6 +25,11 @@ def tag_exists(tag): return False def _test_post(post, tree): + """Test if the list of tags in the post satisfies condition + + Recursively evaluate the tree against the list of tags in the post. + + """ op = tree[0] if op == 'NAME': tag = tree[1] @@ -44,6 +49,11 @@ def _test_post(post, tree): raise ValueError("Cannot get there") def find_tags(tree): + """Test every blog post against parsed expression + + Return all posts that passed the test. + + """ _posts = [] for (year, month, day), posts in blog_dict.iteritems(): for post in posts: @@ -51,5 +61,5 @@ def find_tags(tree): _posts.append(( '/'.join((year, month, day, post[0].replace('.tmpl', '.html'))), post[1])) - _posts.sort() + _posts.sort(reverse=True) return _posts