From: Phil Holmes Date: Sun, 15 Jan 2012 14:19:45 +0000 (+0000) Subject: Final version of not always copying html files X-Git-Tag: release/2.15.25-1~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1a062ada6baa754c009dc16fafb0542e80d4fd1f;p=lilypond.git Final version of not always copying html files --- diff --git a/GNUmakefile.in b/GNUmakefile.in index aa74dd6bd5..d750eb2257 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -122,7 +122,6 @@ WWW-post: # need UTF8 setting in case this is hosted on a website. echo -e 'AddDefaultCharset utf-8\nAddCharset utf-8 .html\nAddCharset utf-8 .en\nAddCharset utf-8 .nl\nAddCharset utf-8 .txt\n' > $(top-build-dir)/.htaccess $(buildscript-dir)/mutopia-index -o $(outdir)/examples.html input/ - find $(outdir) -name '*-root' | xargs rm -rf $(buildscript-dir)/www_post $(PACKAGE_NAME) $(TOPLEVEL_VERSION) $(outdir) "$(WEB_TARGETS)" find $(outdir)/offline-root -type l | xargs rm -f endif # ifeq ($(out),www) diff --git a/python/auxiliar/postprocess_html.py b/python/auxiliar/postprocess_html.py index eed34d1586..ba6d43e09f 100644 --- a/python/auxiliar/postprocess_html.py +++ b/python/auxiliar/postprocess_html.py @@ -350,30 +350,36 @@ def process_html_files (package_name = '', for prefix, ext_list in pages_dict.items (): for lang_ext in ext_list: file_name = langdefs.lang_file_name (prefix, lang_ext, '.html') - in_f = open (file_name) - s = in_f.read() - in_f.close() - - s = s.replace ('%', '%%') - s = hack_urls (s, prefix, target, bool (int (versiontup[1]) % 2)) - s = add_header (s, prefix) - - ### add footer - if footer_tag_re.search (s) == None: - if 'web' in file_name: - s = add_footer (s, footer_tag + web_footer) - else: - s = add_footer (s, footer_tag + footer) - - available, missing = find_translations (prefix, lang_ext) - page_flavors = process_links (s, prefix, lang_ext, file_name, missing, target) - # Add menu after stripping: must not have autoselection for language menu. - page_flavors = add_menu (page_flavors, prefix, available, target, translation) - for k in page_flavors: - page_flavors[k][1] = page_flavors[k][1] % subst[page_flavors[k][0]] - out_f = open (name_filter (k), 'w') - out_f.write (page_flavors[k][1]) - out_f.close() + source_time = os.path.getmtime(file_name) + dest_time = 0 + if os.path.exists(name_filter(file_name)): + dest_time = os.path.getmtime(name_filter(file_name)) + if dest_time < source_time: + + in_f = open (file_name) + s = in_f.read() + in_f.close() + + s = s.replace ('%', '%%') + s = hack_urls (s, prefix, target, bool (int (versiontup[1]) % 2)) + s = add_header (s, prefix) + + ### add footer + if footer_tag_re.search (s) == None: + if 'web' in file_name: + s = add_footer (s, footer_tag + web_footer) + else: + s = add_footer (s, footer_tag + footer) + + available, missing = find_translations (prefix, lang_ext) + page_flavors = process_links (s, prefix, lang_ext, file_name, missing, target) + # Add menu after stripping: must not have autoselection for language menu. + page_flavors = add_menu (page_flavors, prefix, available, target, translation) + for k in page_flavors: + page_flavors[k][1] = page_flavors[k][1] % subst[page_flavors[k][0]] + out_f = open (name_filter (k), 'w') + out_f.write (page_flavors[k][1]) + out_f.close() # if the page is translated, a .en.html symlink is necessary for content negotiation if target == 'online' and ext_list != ['']: os.symlink (os.path.basename (prefix) + '.html', name_filter (prefix + '.en.html')) diff --git a/scripts/build/www_post.py b/scripts/build/www_post.py index fec7f0e20c..7ec91dd80b 100644 --- a/scripts/build/www_post.py +++ b/scripts/build/www_post.py @@ -70,10 +70,15 @@ strip_re = re.compile (outdir + '/') for t in targets: out_root = target_pattern % t strip_file_name[t] = lambda s: os.path.join (target_pattern % t, (strip_re.sub ('', s))) - os.mkdir (out_root) - map (os.mkdir, [os.path.join (out_root, d) for d in dirs]) + if not os.path.exists (out_root): + os.mkdir (out_root) + for d in dirs: + new_dir = os.path.join (out_root, d) + if not os.path.exists (new_dir): + os.mkdir (new_dir) for f in hardlinked_files: - os.link (f, strip_file_name[t] (f)) + if not os.path.isfile (strip_file_name[t] (f)): + os.link (f, strip_file_name[t] (f)) for l in symlinks: p = mirrortree.new_link_path (os.path.normpath (os.readlink (l)), os.path.dirname (l), strip_re) dest = strip_file_name[t] (l)