X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=buildscripts%2Foutput-distance.py;h=e56b1e477de1e044df67092e2269aa19428aabd5;hb=f9214bac21e9926dc3248416f58190c98c4167a9;hp=8939ab27b2f31fe990d86a6d9e06feb878a415c5;hpb=e69b5122d70fa1d8d8b610bed44d3c09aeaddb33;p=lilypond.git diff --git a/buildscripts/output-distance.py b/buildscripts/output-distance.py index 8939ab27b2..e56b1e477d 100644 --- a/buildscripts/output-distance.py +++ b/buildscripts/output-distance.py @@ -7,9 +7,7 @@ import math ## so we can call directly as buildscripts/output-distance.py me_path = os.path.abspath (os.path.split (sys.argv[0])[0]) sys.path.insert (0, me_path + '/../python/') - - -import safeeval +sys.path.insert (0, me_path + '/../python/out/') X_AXIS = 0 @@ -385,8 +383,6 @@ class FileLink: return self.file_names[oldnew] def html_record_string (self, dest_dir): - self.link_files_for_html (dest_dir) - dist = self.distance() details = self.get_distance_details () @@ -394,7 +390,7 @@ class FileLink: details_base = os.path.splitext (self.file_names[1])[0] details_base += '.details.html' fn = dest_dir + '/' + details_base - open (fn, 'w').write (details) + open_write_file (fn).write (details) details = '
(details)' % locals () @@ -439,7 +435,14 @@ class FileCompareLink (FileLink): class GitFileCompareLink (FileCompareLink): def get_cell (self, oldnew): - return self.contents[oldnew] + str = self.contents[oldnew] + + # truncate long lines + str = '\n'.join ([l[:80] for l in str.split ('\n')]) + + + str = '
%s
' % str + return str def calc_distance (self): if self.contents[0] == self.contents[1]: @@ -461,7 +464,7 @@ class TextFileCompareLink (FileCompareLink): self.diff_lines = [l for l in diff] self.diff_lines = self.diff_lines[2:] - return float (len ([l for l in self.diff_lines if l[0] in '-+'])) + return math.sqrt (float (len ([l for l in self.diff_lines if l[0] in '-+']))) def get_cell (self, oldnew): str = '' @@ -483,7 +486,7 @@ class ProfileFileLink (FileCompareLink): str += '%-8s: %d\n' % (k, int (self.results[oldnew][k])) else: str += '%-8s: %8d (%5.3f)\n' % (k, int (self.results[oldnew][k]), - self.get_ratio (k)) + self.get_ratio (k)) return '
%s
' % str @@ -505,30 +508,42 @@ class ProfileFileLink (FileCompareLink): note_info, self.contents[oldnew]) dist = 0.0 - factor = {'time': 1.0 , - 'cells': 10.0, + factor = {'time': 2.0 , + 'cells': 5.0, } for k in ('time', 'cells'): - dist += math.exp (self.get_ratio (k) * factor[k]) - 1 + real_val = math.tan (self.get_ratio (k) * 0.5* math.pi) + dist += math.exp (math.fabs (real_val) * factor[k]) - 1 dist = min (dist, 100) return dist -class MidiFileLink (FileCompareLink): - def get_content (self, f): - s = FileCompareLink.get_content (self, f) - s = re.sub ('LilyPond [0-9.]+', '', s) - return s - - def get_cell (self, oldnew): +class MidiFileLink (TextFileCompareLink): + def get_content (self, oldnew): + import midi + + data = FileCompareLink.get_content (self, oldnew) + midi = midi.parse (data) + tracks = midi[1] + str = '' - if oldnew == 1 and self.distance () > 0: - str = 'changed' + j = 0 + for t in tracks: + str += 'track %d' % j + j += 1 + + for e in t: + ev_str = repr (e) + if re.search ('LilyPond [0-9.]+', ev_str): + continue + + str += ' ev %s\n' % `e` return str + class SignatureFileLink (FileLink): def __init__ (self, f1, f2 ): FileLink.__init__ (self, f1, f2) @@ -915,7 +930,12 @@ class ComparisonData: dest_file = dest_dir + '/index.html' open_write_file (dest_file).write (html) + + + for link in changed: + link.link_files_for_html (dest_dir) + def print_results (self, threshold): self.write_text_result_page ('', threshold)