From 58d26948376ba044380c5259a1fe6286b438e44e Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 15 Mar 2006 15:05:48 +0000 Subject: [PATCH] Blog root. git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@28 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- reindex_blog.py | 14 ++++++++------ reindex_blog_ru | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/reindex_blog.py b/reindex_blog.py index cd6906c..da9f07a 100755 --- a/reindex_blog.py +++ b/reindex_blog.py @@ -10,6 +10,9 @@ __copyright__ = "Copyright (C) 2006 PhiloSoft Design" import sys, os +blog_filename = sys.argv[1] +blog_root = sys.argv[2] + try: import cPickle as pickle except ImportError: @@ -20,7 +23,6 @@ from Cheetah.Template import Template # Load old blog -blog_filename = sys.argv[1] try: blog_file = open(blog_filename, "rb") except IOError: @@ -37,7 +39,7 @@ blog = {} years = {} # Walk the directory recursively -for dirpath, dirs, files in os.walk(os.curdir): +for dirpath, dirs, files in os.walk(blog_root): d = os.path.basename(dirpath) if not d.startswith("20") and not d.isdigit(): continue @@ -56,7 +58,7 @@ for dirpath, dirs, files in os.walk(os.curdir): tags = (tags,) if title: - key = year, month, day = tuple(dirpath.split(os.sep)[1:]) + key = year, month, day = tuple(dirpath[len(blog_root):].split(os.sep)[1:]) if key in blog: days = blog[key] else: @@ -104,7 +106,7 @@ from news import write_if_changed def write_template(level, year, month, day, titles, tags=None): - path = [] + path = [blog_root] if level >= 1: path.append(year) if level >= 2: @@ -346,7 +348,7 @@ for count, tag, links in all_tags: #end def $phd_pp_ru.respond(self) """) - write_if_changed(os.path.join("tags", tag+".tmpl"), ''.join(tag_text)) + write_if_changed(os.path.join(blog_root, "tags", tag+".tmpl"), ''.join(tag_text)) new_text.append("""\ @@ -354,4 +356,4 @@ new_text.append("""\ #end def $phd_pp_ru.respond(self) """) -write_if_changed(os.path.join("tags", "index.tmpl"), ''.join(new_text)) +write_if_changed(os.path.join(blog_root, "tags", "index.tmpl"), ''.join(new_text)) diff --git a/reindex_blog_ru b/reindex_blog_ru index b236f69..37f1376 100755 --- a/reindex_blog_ru +++ b/reindex_blog_ru @@ -5,5 +5,5 @@ umask 022 LC_TIME=ru_RU.KOI8-R export LC_TIME -cd ../htdocs/phd.pp.ru/Russian/blog && \ -exec ../../../../phd.pp.ru/reindex_blog.py ../../../../phd.pp.ru/blog_ru "$@" +cd ../htdocs/phd.pp.ru && \ +exec ../../phd.pp.ru/reindex_blog.py ../../phd.pp.ru/blog_ru Russian/blog -- 2.39.5