def translate_path(self, path): fs_path = SimpleHTTPRequestHandler.translate_path(self, path) if self.path.endswith('/'): for index in "index.html", "index.htm": index = os.path.join(fs_path, index) if os.path.exists(index): fs_path = index break if fs_path.endswith('.html'): content = ssi.InlineIncludes(fs_path) fs_path = self.create_temp_file(fs_path, content) return fs_path
def process(source, dest): for dirpath, dirnames, filenames in os.walk(source): dest_dir = os.path.realpath(os.path.join(dest, os.path.relpath(dirpath, source))) os.mkdir(dest_dir) for filename in filenames: src_path = os.path.abspath(os.path.join(source, dirpath, filename)) dest_path = os.path.join(dest_dir, filename) if not filename.endswith('.html'): os.symlink(src_path, dest_path) else: file(dest_path, 'w').write(ssi.InlineIncludes(src_path)) # ignore hidden directories for dirname in dirnames[:]: if dirname.startswith('.'): dirnames.remove(dirname)