import os __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2017-2024 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()