--- /dev/null
+#! /usr/bin/env python
+
+import sys, os
+
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2017 PhiloSoft Design"
+
+blog_data_root = os.path.dirname(__file__)
+blog_root = os.path.join(blog_data_root, '../htdocs/phdru.name/Russian/blog')
+blog_filename = os.path.join(blog_data_root, "ru/blog_dict.pickle")
+
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+def load_blog():
+ try:
+ blog_file = open(blog_filename, "rb")
+ except IOError:
+ blog = {}
+ else:
+ blog = pickle.load(blog_file)
+ blog_file.close()
+ return blog
+
+def save_blog(blog):
+ blog_file = open(blog_filename, "wb")
+ pickle.dump(blog, blog_file, pickle.HIGHEST_PROTOCOL)
+ blog_file.close()
__copyright__ = "Copyright (C) 2006-2017 PhiloSoft Design"
import sys, os
-from Cheetah.compat import string_type
-
-blog_data_root = sys.argv[1]
-blog_root = sys.argv[2]
-blog_filename = os.path.join(blog_data_root, "blog_dict.pickle")
-
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
-
from Cheetah.Template import Template
+from Cheetah.compat import string_type
+from blog_db import blog_root, load_blog, save_blog
-# Load old blog
-
-try:
- blog_file = open(blog_filename, "rb")
-except IOError:
- old_blog = {}
-else:
- old_blog = pickle.load(blog_file)
- blog_file.close()
-
+old_blog = load_blog()
# blog is a dictionary mapping
# (year, month, day) => [list of (file, title, lead, tags)]
bodies[key] = body
# Need to save the blog?
-if blog <> old_blog:
- blog_file = open(blog_filename, "wb")
- pickle.dump(blog, blog_file, pickle.HIGHEST_PROTOCOL)
- blog_file.close()
+if blog != old_blog:
+ save_blog(blog)
# Localized month names
export LC_TIME
cd ../htdocs/phdru.name &&
-exec ../../phdru.name/reindex_blog.py ../../phdru.name/ru Russian/blog
+exec ../../phdru.name/reindex_blog.py