def _start_song(self, lilypond_file): if self._debug: print 'Song loaded: %s' % lilypond_file notes = parse_file(lilypond_file) self._matcher.load_piece(notes)
parser.add_option('-o', dest='algorithm_options', action='append', metavar='OPTION[=VALUE]', help='set an algorithm option') parser.add_option('-d', '--debug', action='store_true', help='show debugging output') parser.set_defaults(algorithm='simple', debug=False) options, args = parser.parse_args() try: # read the instruction file instructions = read_note_file(args[0]) # read the LilyPond score if not args[1].endswith('.ly'): parser.error('looks like you did that backwards') notes = parse_file(args[1]) except IndexError: parser.error('missing an argument') # Load the matching algorithm implementation try: algorithm_class = get_algorithm(options.algorithm) algorithm_options = parse_algorithm_options(options.algorithm_options) algorithm = algorithm_class(**algorithm_options) except ValueError, e: parser.error(e[0]) # run the test tester = Tester(notes, instructions, algorithm, options.debug) tester.test()