From: Han-Wen Nienhuys Date: Mon, 29 May 2006 10:39:29 +0000 (+0000) Subject: (ComparisonData.create_html_result_page): new routine: summarise X-Git-Tag: release/2.9.7~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aca2cc8112d5e897a9937f92d723c8016d4e81f9;p=lilypond.git (ComparisonData.create_html_result_page): new routine: summarise results in HTML page with images. --- diff --git a/ChangeLog b/ChangeLog index 1c52cf0069..aeb7633117 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 2006-05-29 Han-Wen Nienhuys + * buildscripts/output-distance.py + (ComparisonData.create_html_result_page): new routine: summarise + results in HTML page with images. + * GNUmakefile.in (web-ext): package .signature files too. They - compress well. + compress well. BackportmeStart. * scm/stencil.scm (write-system-signature): typo. @@ -13,8 +17,6 @@ * scm/framework-ps.scm (output-framework): dump-signatures support for plain output. - * GNUmakefile.in: create web-signature-root/ too - * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): add -ddump-signatures. * scm/framework-ps.scm (write-preamble): redefine mark_URI to nop @@ -63,7 +65,8 @@ * scm/stencil.scm (write-system-signature): new routine: write python parseable signature of a separate paper system. - + BackportmeEnd. + 2006-05-26 Han-Wen Nienhuys * lily/stanza-number-engraver.cc (process_music): use is_markup() diff --git a/buildscripts/output-distance.py b/buildscripts/output-distance.py index 236b497ece..84ca8bd82f 100644 --- a/buildscripts/output-distance.py +++ b/buildscripts/output-distance.py @@ -167,6 +167,8 @@ class SystemLink: # Files/directories import glob +import shutil +import re def read_signature_file (name): print 'reading', name @@ -233,17 +235,17 @@ class ComparisonData: self.added += [(dir2, m) for m in m2] for p in paired: - f = dir1 + '/' +p - d = compare_signature_files (f, dir2 + '/' +p) - self.result_dict[f] = d - + f2 = dir2 + '/' + p + f1 = dir1 + '/' + p + distance = compare_signature_files (f1, f2) + self.result_dict[f2] = (distance, f1) def print_results (self): - results = [(score, file) for (file, score) in self.result_dict.items ()] + results = [(score, oldfile, file) for (file, (score, oldfile)) in self.result_dict.items ()] results.sort () results.reverse () - for (s, f) in results: + for (s, oldfile, f) in results: print '%30s %6f' % (f,s) for (dir, file) in self.missing: @@ -251,11 +253,81 @@ class ComparisonData: for (dir, file) in self.added: print '%10s%-10s %s' % ('','added', os.path.join (dir, file)) + def create_html_result_page (self, dir1, dir2): + dir1 = dir1.replace ('//', '/') + dir2 = dir2.replace ('//', '/') + + threshold = 1.0 + + results = [(score, oldfile, file) for (file, (score, oldfile)) in self.result_dict.items () + if score > threshold] + + results.sort () + results.reverse () + + html = '' + old_prefix = os.path.split (dir1)[1] + os.mkdir (dir2 + '/' + old_prefix) + for (score, oldfile, newfile) in results: + old_base = re.sub ("-[0-9]+.signature", '', os.path.split (oldfile)[1]) + new_base = re.sub ("-[0-9]+.signature", '', newfile) + + for ext in 'png', 'ly': + shutil.copy2 (old_base + '.' + ext, dir2 + '/' + old_prefix) + + img_1 = os.path.join (old_prefix, old_base + '.png') + ly_1 = os.path.join (old_prefix, old_base + '.ly') + + img_2 = new_base.replace (dir2, '') + '.png' + img_2 = re.sub ("^/*", '', img_2) + + ly_2 = img_2.replace ('.png','.ly') + + def img_cell (ly, img): + return ''' + + + +
+(source) + + +''' % locals () + + html_entry = ''' + + +%f + + +%s +%s + +''' % (score, img_cell (ly_1, img_1), img_cell (ly_2, img_2)) + + + html += html_entry + + html = ''' + + + + + + +%(html)s +
distanceoldnew
+''' % locals() + + open (os.path.join (dir2, old_prefix) + '.html', 'w').write (html) + + def compare_trees (dir1, dir2): data = ComparisonData () data.compare_trees (dir1, dir2) data.print_results () + data.create_html_result_page (dir1, dir2) ################################################################ # TESTING @@ -275,12 +347,15 @@ def test_paired_files (): def test_compare_trees (): system ('rm -rf dir1 dir2') system ('mkdir dir1 dir2') - system ('cp 20-0.signature dir1') - system ('cp 20expr-0.signature dir1') + system ('cp 20{-0.signature,.ly,.png} dir1') + system ('cp 20{-0.signature,.ly,.png} dir2') + system ('cp 20expr{-0.signature,.ly,.png} dir1') + system ('cp 19{-0.signature,.ly,.png} dir2/') + system ('cp 19{-0.signature,.ly,.png} dir1/') + system ('cp 20grob{-0.signature,.ly,.png} dir2/') + + ## introduce difference system ('cp 19-0.signature dir2/20-0.signature') - system ('cp 19-0.signature dir2/') - system ('cp 19-0.signature dir1/') - system ('cp 20grob-0.signature dir2/') compare_trees ('dir1', 'dir2') @@ -292,10 +367,6 @@ def test_basic_compare (): (print-score-with-defaults p (scorify-music m p))))) -#(ly:set-option 'point-and-click) - - - %(papermod)s \relative c { @@ -303,7 +374,6 @@ def test_basic_compare (): } """ - dicts = [{ 'papermod' : '', 'name' : '20', 'extragrob': '', @@ -327,7 +397,7 @@ def test_basic_compare (): names = [d['name'] for d in dicts] - system ('lilypond -ddump-signatures -b eps ' + ' '.join (names)) + system ('lilypond -ddump-signatures --png -b eps ' + ' '.join (names)) sigs = dict ((n, read_signature_file ('%s-0.signature' % n)) for n in names) @@ -337,7 +407,7 @@ def test_basic_compare (): combinations['%s-%s' % (n1, n2)] = SystemLink (s1,s2).distance () - results = combinations.items () + results = combinations.items () results.sort () for k,v in results: print '%-20s' % k, v @@ -354,37 +424,41 @@ def test_sigs (a,b): def run_tests (): + do_clean = 1 dir = 'output-distance-test' print 'test results in ', dir - system ('rm -rf ' + dir) - system ('mkdir ' + dir) + if do_clean: + system ('rm -rf ' + dir) + system ('mkdir ' + dir) + os.chdir (dir) - test_compare_trees () test_basic_compare () + test_compare_trees () ################################################################ # def main (): p = optparse.OptionParser ("output-distance - compare LilyPond formatting runs") - p.usage ('output-distance.py [options] tree1 tree2') + p.usage = 'output-distance.py [options] tree1 tree2' p.add_option ('', '--test', dest="run_test", + action="store_true", help='run test method') (o,a) = p.parse_args () - if len (a) != 2: - p.usage() - sys.exit (2) - if o.run_test: run_tests () sys.exit (0) + if len (a) != 2: + p.print_usage() + sys.exit (2) + compare_trees (a[0], a[1]) if __name__ == '__main__':