6 ## so we can call directly as buildscripts/output-distance.py
7 me_path = os.path.abspath (os.path.split (sys.argv[0])[0])
8 sys.path.insert (0, me_path + '/../python/')
18 OUTPUT_EXPRESSION_PENALTY = 1
19 ORPHAN_GROB_PENALTY = 1
22 def shorten_string (s):
24 if len (s) > 2*threshold:
25 s = s[:threshold] + '..' + s[-threshold:]
28 def max_distance (x1, x2):
31 for (p,q) in zip (x1, x2):
32 dist = max (abs (p-q), dist)
37 empty_interval = (INFTY, -INFTY)
38 empty_bbox = (empty_interval, empty_interval)
40 def interval_is_empty (i):
43 def interval_length (i):
44 return max (i[1]-i[0], 0)
46 def interval_union (i1, i2):
47 return (min (i1[0], i2[0]),
50 def interval_intersect (i1, i2):
51 return (max (i1[0], i2[0]),
54 def bbox_is_empty (b):
55 return (interval_is_empty (b[0])
56 or interval_is_empty (b[1]))
58 def bbox_union (b1, b2):
59 return (interval_union (b1[X_AXIS], b2[X_AXIS]),
60 interval_union (b2[Y_AXIS], b2[Y_AXIS]))
62 def bbox_intersection (b1, b2):
63 return (interval_intersect (b1[X_AXIS], b2[X_AXIS]),
64 interval_intersect (b2[Y_AXIS], b2[Y_AXIS]))
67 return interval_length (b[X_AXIS]) * interval_length (b[Y_AXIS])
69 def bbox_diameter (b):
70 return max (interval_length (b[X_AXIS]),
71 interval_length (b[Y_AXIS]))
74 def difference_area (a, b):
75 return bbox_area (a) - bbox_area (bbox_intersection (a,b))
78 def __init__ (self, exp_list):
79 (self.name, self.origin, bbox_x,
80 bbox_y, self.output_expression) = tuple (exp_list)
82 self.bbox = (bbox_x, bbox_y)
83 self.centroid = (bbox_x[0] + bbox_x[1], bbox_y[0] + bbox_y[1])
86 return '%s: (%.2f,%.2f), (%.2f,%.2f)\n' % (self.name,
92 def axis_centroid (self, axis):
93 return apply (sum, self.bbox[axis]) / 2
95 def centroid_distance (self, other, scale):
96 return max_distance (self.centroid, other.centroid) / scale
98 def bbox_distance (self, other):
99 divisor = bbox_area (self.bbox) + bbox_area (other.bbox)
102 return (difference_area (self.bbox, other.bbox) +
103 difference_area (other.bbox, self.bbox)) / divisor
107 def expression_distance (self, other):
108 if self.output_expression == other.output_expression:
113 ################################################################
116 class SystemSignature:
117 def __init__ (self, grob_sigs):
120 val = d.setdefault (g.name, [])
124 self.set_all_bbox (grob_sigs)
126 def set_all_bbox (self, grobs):
127 self.bbox = empty_bbox
129 self.bbox = bbox_union (g.bbox, self.bbox)
131 def closest (self, grob_name, centroid):
135 grobs = self.grob_dict[grob_name]
138 d = max_distance (g.centroid, centroid)
149 return reduce (lambda x,y: x+y, self.grob_dict.values(), [])
151 ################################################################
152 ## comparison of systems.
155 def __init__ (self, system1, system2):
156 self.system1 = system1
157 self.system2 = system2
159 self.link_list_dict = {}
160 self.back_link_dict = {}
167 self.geo_distances = {}
170 self.expression_changed = []
172 self._geometric_distance = None
173 self._expression_change_count = None
174 self._orphan_count = None
176 for g in system1.grobs ():
178 ## skip empty bboxes.
179 if bbox_is_empty (g.bbox):
182 closest = system2.closest (g.name, g.centroid)
184 self.link_list_dict.setdefault (closest, [])
185 self.link_list_dict[closest].append (g)
186 self.back_link_dict[g] = closest
189 def calc_geometric_distance (self):
191 for (g1,g2) in self.back_link_dict.items ():
193 d = g1.bbox_distance (g2)
195 self.geo_distances[(g1,g2)] = d
199 self._geometric_distance = total
201 def calc_orphan_count (self):
203 for (g1, g2) in self.back_link_dict.items ():
205 self.orphans.append ((g1, None))
209 self._orphan_count = count
211 def calc_output_exp_distance (self):
213 for (g1,g2) in self.back_link_dict.items ():
215 d += g1.expression_distance (g2)
217 self._expression_change_count = d
219 def output_expression_details_string (self):
220 return ', '.join ([g1.name for g1 in self.expression_changed])
222 def geo_details_string (self):
223 results = [(d, g1,g2) for ((g1, g2), d) in self.geo_distances.items()]
227 return ', '.join (['%s: %f' % (g1.name, d) for (d, g1, g2) in results])
229 def orphan_details_string (self):
230 return ', '.join (['%s-None' % g1.name for (g1,g2) in self.orphans if g2==None])
232 def geometric_distance (self):
233 if self._geometric_distance == None:
234 self.calc_geometric_distance ()
235 return self._geometric_distance
237 def orphan_count (self):
238 if self._orphan_count == None:
239 self.calc_orphan_count ()
241 return self._orphan_count
243 def output_expression_change_count (self):
244 if self._expression_change_count == None:
245 self.calc_output_exp_distance ()
246 return self._expression_change_count
249 return (self.output_expression_change_count (),
250 self.orphan_count (),
251 self.geometric_distance ())
253 def read_signature_file (name):
254 print 'reading', name
256 entries = open (name).read ().split ('\n')
257 def string_to_tup (s):
258 return tuple (map (float, s.split (' ')))
260 def string_to_entry (s):
261 fields = s.split('@')
262 fields[2] = string_to_tup (fields[2])
263 fields[3] = string_to_tup (fields[3])
265 return tuple (fields)
267 entries = [string_to_entry (e) for e in entries
268 if e and not e.startswith ('#')]
270 grob_sigs = [GrobSignature (e) for e in entries]
271 sig = SystemSignature (grob_sigs)
275 ################################################################
276 # different systems of a .ly file.
279 return os.popen (c).read ()
285 raise Exception ("failed")
288 def compare_png_images (old, new, dir):
290 m = re.search ('([0-9]+) x ([0-9]+)', read_pipe ('file %s' % f))
292 return tuple (map (int, m.groups ()))
294 dest = os.path.join (dir, new.replace ('.png', '.compare.jpeg'))
296 dims1 = png_dims (old)
297 dims2 = png_dims (new)
298 except AttributeError:
300 system ('touch %(dest)s' % locals ())
303 dims = (min (dims1[0], dims2[0]),
304 min (dims1[1], dims2[1]))
306 system ('convert -depth 8 -crop %dx%d+0+0 %s crop1.png' % (dims + (old,)))
307 system ('convert -depth 8 -crop %dx%d+0+0 %s crop2.png' % (dims + (new,)))
309 system ('compare -depth 8 crop1.png crop2.png diff.png')
311 system ("convert -depth 8 diff.png -blur 0x3 -negate -channel alpha,blue -type TrueColorMatte -fx 'intensity' matte.png")
313 system ("composite -quality 65 matte.png %(new)s %(dest)s" % locals ())
317 self._distance = None
319 def text_record_string (self):
320 return '%-30f %-20s\n' % (self.distance (),
322 def calc_distance (self):
326 if self._distance == None:
327 self._distance = self.calc_distance ()
329 return self._distance
334 def link_files_for_html (self, old_dir, new_dir, dest_dir):
337 def write_html_system_details (self, dir1, dir2, dest_dir):
340 def html_record_string (self, old_dir, new_dir):
343 class FileCompareLink (FileLink):
344 def __init__ (self, f1, f2):
345 FileLink.__init__ (self)
346 self.files = (f1, f2)
347 self.contents = (self.get_content (self.files[0]),
348 self.get_content (self.files[1]))
351 name = os.path.basename (self.files[0])
352 name = os.path.splitext (name)[0]
355 def calc_distance (self):
356 ## todo: could use import MIDI to pinpoint
357 ## what & where changed.
359 if self.contents[0] == self.contents[1]:
364 def html_record_string (self, d1, d2):
371 </tr>''' % ((self.distance(),) + self.files)
373 def get_content (self, f):
377 class TextFileCompareLink (FileCompareLink):
378 def calc_distance (self):
380 diff = difflib.unified_diff (self.contents[0].split ('\n'),
381 self.contents[1].split ('\n'),
382 fromfiledate = self.files[0],
383 tofiledate = self.files[1]
386 self.diff_lines = [l for l in diff]
387 return float (len (self.diff_lines))
389 def link_files_for_html (self, old_dir, new_dir, dest_dir):
390 str = '\n'.join ([d.replace ('\n','') for d in self.diff_lines])
391 f = os.path.join (new_dir, self.name ()) + '.diff.txt'
392 f = os.path.join (dest_dir, f)
393 open_write_file (f).write (str)
395 def html_record_string (self, d1, d2):
401 <td><a href="%s.diff.txt"><tt>%s</tt></a></td>
402 </tr>''' % (self.distance(),
404 os.path.join (d2, self.name ()),
407 class MidiFileLink (FileCompareLink):
408 def get_content (self, f):
410 s = re.sub ('LilyPond [0-9.]+', '', s)
413 class SignatureFileLink (FileLink):
415 FileLink.__init__ (self)
416 self.original_name = ''
417 self.base_names = ('','')
418 self.system_links = {}
421 return os.path.splitext (self.original_name)[0]
423 def add_system_link (self, link, number):
424 self.system_links[number] = link
426 def calc_distance (self):
429 orphan_distance = 0.0
430 for l in self.system_links.values ():
431 d = max (d, l.geometric_distance ())
432 orphan_distance += l.orphan_count ()
434 return d + orphan_distance
436 def source_file (self):
437 for ext in ('.ly', '.ly.txt'):
438 if os.path.exists (self.base_names[1] + ext):
439 return self.base_names[1] + ext
442 def add_file_compare (self, f1, f2):
445 def note_system_index (m):
446 system_index.append (int (m.group (1)))
449 base1 = re.sub ("-([0-9]+).signature", note_system_index, f1)
450 base2 = re.sub ("-([0-9]+).signature", note_system_index, f2)
452 self.base_names = (os.path.normpath (base1),
453 os.path.normpath (base2))
455 def note_original (match):
456 self.original_name = match.group (1)
459 if not self.original_name:
460 self.original_name = os.path.split (base1)[1]
462 ## ugh: drop the .ly.txt
463 for ext in ('.ly', '.ly.txt'):
465 re.sub (r'\\sourcefilename "([^"]+)"',
466 note_original, open (base1 + ext).read ())
470 s1 = read_signature_file (f1)
471 s2 = read_signature_file (f2)
473 link = SystemLink (s1, s2)
475 self.add_system_link (link, system_index[0])
478 def create_images (self, old_dir, new_dir, dest_dir):
480 files_created = [[], []]
481 for oldnew in (0, 1):
482 pat = self.base_names[oldnew] + '.eps'
484 for f in glob.glob (pat):
486 outfile = (dest_dir + '/' + f).replace ('.eps', '.png')
488 mkdir (os.path.split (outfile)[0])
489 cmd = ('gs -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 '
491 ' -sOutputFile=%(outfile)s -dNOSAFER -dEPSCrop -q -dNOPAUSE '
492 ' %(infile)s -c quit ' % locals ())
494 files_created[oldnew].append (outfile)
499 def link_files_for_html (self, old_dir, new_dir, dest_dir):
500 to_compare = [[], []]
503 if options.create_images:
504 to_compare = self.create_images (old_dir, new_dir, dest_dir)
506 exts += ['.png', '-page*png']
510 for f in glob.glob (self.base_names[oldnew] + ext):
511 dst = dest_dir + '/' + f
514 if f.endswith ('.png'):
515 to_compare[oldnew].append (f)
517 if options.compare_images:
518 for (old, new) in zip (to_compare[0], to_compare[1]):
519 compare_png_images (old, new, dest_dir)
522 def html_record_string (self, old_dir, new_dir):
523 def img_cell (ly, img, name):
527 name = '<tt>%s</tt>' % name
532 <img src="%(img)s" style="border-style: none; max-width: 500px;">
534 <font size="-2">(<a href="%(ly)s">%(name)s</a>)
538 def multi_img_cell (ly, imgs, name):
542 name = '<tt>%s</tt>' % name
544 imgs_str = '\n'.join (['''<a href="%s">
545 <img src="%s" style="border-style: none; max-width: 500px;">
546 </a><br>''' % (img, img)
553 <font size="-2">(<a href="%(ly)s">%(name)s</a>)
560 def cell (base, name):
561 pat = base + '-page*.png'
562 pages = glob.glob (pat)
565 return multi_img_cell (base + '.ly', sorted (pages), name)
567 return img_cell (base + '.ly', base + '.png', name)
570 html_2 = self.base_names[1] + '.html'
571 name = self.original_name
573 cell_1 = cell (self.base_names[0], name)
574 cell_2 = cell (self.base_names[1], name)
575 if options.compare_images:
576 cell_2 = cell_2.replace ('.png', '.compare.jpeg')
582 (<a href="%s">details</a>)
588 ''' % (self.distance (), html_2, cell_1, cell_2)
593 def html_system_details_string (self):
594 systems = self.system_links.items ()
598 for (c, link) in systems:
599 e = '<td>%d</td>' % c
600 for d in link.distance ():
601 e += '<td>%f</td>' % d
603 e = '<tr>%s</tr>' % e
607 e = '<td>%d</td>' % c
608 for s in (link.output_expression_details_string (),
609 link.orphan_details_string (),
610 link.geo_details_string ()):
611 e += "<td>%s</td>" % s
614 e = '<tr>%s</tr>' % e
617 original = self.original_name
620 <title>comparison details for %(original)s</title>
639 def write_html_system_details (self, dir1, dir2, dest_dir):
640 dest_file = os.path.join (dest_dir, self.base_names[1] + '.html')
642 details = open_write_file (dest_file)
643 details.write (self.html_system_details_string ())
645 ################################################################
651 def compare_signature_files (f1, f2):
652 s1 = read_signature_file (f1)
653 s2 = read_signature_file (f2)
655 return SystemLink (s1, s2).distance ()
657 def paired_files (dir1, dir2, pattern):
659 Search DIR1 and DIR2 for PATTERN.
661 Return (PAIRED, MISSING-FROM-2, MISSING-FROM-1)
665 files1 = dict ((os.path.split (f)[1], 1) for f in glob.glob (dir1 + '/' + pattern))
666 files2 = dict ((os.path.split (f)[1], 1) for f in glob.glob (dir2 + '/' + pattern))
670 for f in files1.keys ():
677 return (pairs, files2.keys (), missing)
679 class ComparisonData:
681 self.result_dict = {}
686 def compare_trees (self, dir1, dir2):
687 self.compare_directories (dir1, dir2)
689 (root, dirs, files) = os.walk (dir1).next ()
691 d1 = os.path.join (dir1, d)
692 d2 = os.path.join (dir2, d)
694 if os.path.islink (d1) or os.path.islink (d2):
697 if os.path.isdir (d2):
698 self.compare_trees (d1, d2)
700 def compare_directories (self, dir1, dir2):
701 for ext in ['signature', 'midi', 'log']:
702 (paired, m1, m2) = paired_files (dir1, dir2, '*.' + ext)
704 self.missing += [(dir1, m) for m in m1]
705 self.added += [(dir2, m) for m in m2]
708 if (options.max_count
709 and len (self.file_links) > options.max_count):
715 self.compare_files (f1, f2)
717 def compare_files (self, f1, f2):
718 if f1.endswith ('signature'):
719 self.compare_signature_files (f1, f2)
720 elif f1.endswith ('midi'):
721 self.compare_midi_files (f1, f2)
722 elif f1.endswith ('log'):
723 self.compare_ascii_files (f1, f2)
725 def compare_general_files (self, f1, f2):
726 name = os.path.split (f1)[1]
728 file_link = FileCompareLink (f1, f2)
729 self.file_links[name] = file_link
731 def compare_ascii_files (self, f1, f2):
732 name = os.path.split (f1)[1]
734 file_link = TextFileCompareLink (f1, f2)
735 self.file_links[name] = file_link
738 def compare_midi_files (self, f1, f2):
739 name = os.path.split (f1)[1]
741 file_link = MidiFileLink (f1, f2)
742 self.file_links[name] = file_link
744 def compare_signature_files (self, f1, f2):
745 name = os.path.split (f1)[1]
746 name = re.sub ('-[0-9]+.signature', '', name)
750 file_link = self.file_links[name]
752 file_link = SignatureFileLink ()
753 self.file_links[name] = file_link
755 file_link.add_file_compare (f1, f2)
757 def remove_changed (self, dir, threshold):
758 (changed, below, unchanged) = self.thresholded_results (threshold)
761 system ('rm -f %s*' % link.base_names[1])
762 except AttributeError: ### UGH.
763 system ('rm -f %s/%s*' % (dir, link.name ()))
764 def thresholded_results (self, threshold):
765 ## todo: support more scores.
766 results = [(link.distance(), link)
767 for link in self.file_links.values ()]
771 unchanged = [r for (d,r) in results if d == 0.0]
772 below = [r for (d,r) in results if threshold >= d > 0.0]
773 changed = [r for (d,r) in results if d > threshold]
775 return (changed, below, unchanged)
777 def write_text_result_page (self, filename, threshold):
782 print 'writing "%s"' % filename
783 out = open_write_file (filename)
785 (changed, below, unchanged) = self.thresholded_results (threshold)
789 out.write (link.text_record_string ())
792 out.write ('%d below threshold\n' % len (below))
793 out.write ('%d unchanged\n' % len (unchanged))
795 def create_text_result_page (self, dir1, dir2, dest_dir, threshold):
796 self.write_text_result_page (dest_dir + '/index.txt', threshold)
798 def create_html_result_page (self, dir1, dir2, dest_dir, threshold):
799 dir1 = dir1.replace ('//', '/')
800 dir2 = dir2.replace ('//', '/')
802 (changed, below, unchanged) = self.thresholded_results (threshold)
806 old_prefix = os.path.split (dir1)[1]
808 link.link_files_for_html (dir1, dir2, dest_dir)
809 link.write_html_system_details (dir1, dir2, dest_dir)
811 html += link.html_record_string (dir1, dir2)
814 short_dir1 = shorten_string (dir1)
815 short_dir2 = shorten_string (dir2)
817 <table rules="rows" border bordercolor="blue">
820 <th>%(short_dir1)s</th>
821 <th>%(short_dir2)s</th>
825 </html>''' % locals()
828 below_count = len (below)
831 html += ('<p>%d below threshold</p>' % below_count)
833 html += ('<p>%d unchanged</p>' % len (unchanged))
835 dest_file = dest_dir + '/index.html'
836 open_write_file (dest_file).write (html)
838 def print_results (self, threshold):
839 self.write_text_result_page ('', threshold)
841 def compare_trees (dir1, dir2, dest_dir, threshold):
842 data = ComparisonData ()
843 data.compare_trees (dir1, dir2)
844 data.print_results (threshold)
846 if options.remove_changed:
847 data.remove_changed (dir2, threshold)
850 if os.path.isdir (dest_dir):
851 system ('rm -rf %s '% dest_dir)
853 data.create_html_result_page (dir1, dir2, dest_dir, threshold)
854 data.create_text_result_page (dir1, dir2, dest_dir, threshold)
856 ################################################################
860 if not os.path.isdir (x):
864 def link_file (x, y):
865 mkdir (os.path.split (y)[0])
869 print 'OSError', x, y, z
872 def open_write_file (x):
873 d = os.path.split (x)[0]
885 def test_paired_files ():
886 print paired_files (os.environ["HOME"] + "/src/lilypond/scripts/",
887 os.environ["HOME"] + "/src/lilypond-stable/buildscripts/", '*.py')
890 def test_compare_trees ():
891 system ('rm -rf dir1 dir2')
892 system ('mkdir dir1 dir2')
893 system ('cp 20{-*.signature,.ly,.png,.eps,.log} dir1')
894 system ('cp 20{-*.signature,.ly,.png,.eps,.log} dir2')
895 system ('cp 20expr{-*.signature,.ly,.png,.eps,.log} dir1')
896 system ('cp 19{-*.signature,.ly,.png,.eps,.log} dir2/')
897 system ('cp 19{-*.signature,.ly,.png,.eps,.log} dir1/')
898 system ('cp 19-1.signature 19-sub-1.signature')
899 system ('cp 19.ly 19-sub.ly')
900 system ('cp 19.log 19-sub.log')
901 system ('cp 19.png 19-sub.png')
902 system ('cp 19.eps 19-sub.eps')
904 system ('cp 20multipage* dir1')
905 system ('cp 20multipage* dir2')
906 system ('cp 19multipage-1.signature dir2/20multipage-1.signature')
909 system ('mkdir -p dir1/subdir/ dir2/subdir/')
910 system ('cp 19-sub{-*.signature,.ly,.png,.eps,.log} dir1/subdir/')
911 system ('cp 19-sub{-*.signature,.ly,.png,.eps,.log} dir2/subdir/')
912 system ('cp 20grob{-*.signature,.ly,.png,.eps,.log} dir2/')
913 system ('cp 20grob{-*.signature,.ly,.png,.eps,.log} dir1/')
915 ## introduce differences
916 system ('cp 19-1.signature dir2/20-1.signature')
917 system ('cp 19.png dir2/20.png')
918 system ('cp 19multipage-page1.png dir2/20multipage-page1.png')
919 system ('cp 20-1.signature dir2/subdir/19-sub-1.signature')
920 system ('cp 20.png dir2/subdir/19-sub.png')
923 system ('cp 19-1.signature dir2/20grob-1.signature')
924 system ('cp 19-1.signature dir2/20grob-2.signature')
925 system ('cp 19multipage.midi dir1/midi-differ.midi')
926 system ('cp 20multipage.midi dir2/midi-differ.midi')
927 system ('cp 19multipage.log dir1/log-differ.log')
928 system ('cp 19multipage.log dir2/log-differ.log && echo different >> dir2/log-differ.log && echo different >> dir2/log-differ.log')
930 compare_trees ('dir1', 'dir2', 'compare-dir1dir2', 0.5)
933 def test_basic_compare ():
937 #(define default-toplevel-book-handler
938 print-book-with-defaults-as-systems )
940 #(ly:set-option (quote no-point-and-click))
942 \sourcefilename "my-source.ly"
945 \header { tagline = ##f }
948 \new Staff \relative c {
949 c4^"%(userstring)s" %(extragrob)s
951 \new Staff \relative c {
952 c4^"%(userstring)s" %(extragrob)s
960 dicts = [{ 'papermod' : '',
963 'userstring': 'test' },
964 { 'papermod' : '#(set-global-staff-size 19.5)',
967 'userstring': 'test' },
971 'userstring': 'blabla' },
974 'extragrob': 'r2. \\break c1',
975 'userstring': 'test' },
979 open (d['name'] + '.ly','w').write (ly_template % d)
981 names = [d['name'] for d in dicts]
983 system ('lilypond -dseparate-log-files -ddump-signatures --png -b eps ' + ' '.join (names))
987 #(set-default-paper-size "a6")
989 \relative {c1 \pageBreak c1 }
995 open ('20multipage', 'w').write (multipage_str.replace ('c1', 'd1'))
996 open ('19multipage', 'w').write ('#(set-global-staff-size 19.5)\n' + multipage_str)
997 system ('lilypond -dseparate-log-files -ddump-signatures --png 19multipage 20multipage ')
999 test_compare_signatures (names)
1001 def test_compare_signatures (names, timing=False):
1012 for t in range (0, times):
1013 sigs = dict ((n, read_signature_file ('%s-1.signature' % n)) for n in names)
1017 print 'elapsed', (time.clock() - t0)/count
1023 for (n1, s1) in sigs.items():
1024 for (n2, s2) in sigs.items():
1025 combinations['%s-%s' % (n1, n2)] = SystemLink (s1,s2).distance ()
1029 print 'elapsed', (time.clock() - t0)/count
1031 results = combinations.items ()
1034 print '%-20s' % k, v
1036 assert combinations['20-20'] == (0.0,0.0,0.0)
1037 assert combinations['20-20expr'][0] > 0.0
1038 assert combinations['20-19'][2] < 10.0
1039 assert combinations['20-19'][2] > 0.0
1043 dir = 'test-output-distance'
1045 do_clean = not os.path.exists (dir)
1047 print 'test results in ', dir
1049 system ('rm -rf ' + dir)
1050 system ('mkdir ' + dir)
1054 test_basic_compare ()
1056 test_compare_trees ()
1058 ################################################################
1062 p = optparse.OptionParser ("output-distance - compare LilyPond formatting runs")
1063 p.usage = 'output-distance.py [options] tree1 tree2'
1065 p.add_option ('', '--test-self',
1067 action="store_true",
1068 help='run test method')
1070 p.add_option ('--max-count',
1076 help='only analyze COUNT signature pairs')
1078 p.add_option ('', '--threshold',
1083 help='threshold for geometric distance')
1086 p.add_option ('--remove-changed',
1087 dest="remove_changed",
1089 action="store_true",
1090 help="Remove all files from tree2 that are over the threshold.")
1092 p.add_option ('--no-compare-images',
1093 dest="compare_images",
1095 action="store_false",
1096 help="Don't run graphical comparisons")
1098 p.add_option ('--create-images',
1099 dest="create_images",
1101 action="store_true",
1102 help="Create PNGs from EPSes")
1104 p.add_option ('-o', '--output-dir',
1109 help='where to put the test results [tree2/compare-tree1tree2]')
1112 (options, a) = p.parse_args ()
1114 if options.run_test:
1122 name = options.output_dir
1124 name = a[0].replace ('/', '')
1125 name = os.path.join (a[1], 'compare-' + shorten_string (name))
1127 compare_trees (a[0], a[1], name, options.threshold)
1129 if __name__ == '__main__':