## 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
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 ()
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 = '<br>(<a href="%(details_base)s">details</a>)' % locals ()
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 = '<font size="-2"><pre>%s</pre></font>' % str
+ return str
def calc_distance (self):
if self.contents[0] == self.contents[1]:
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 = ''
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 '<pre>%s</pre>' % str
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)
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)