From d5ce34e592e14f45b11334374d794a01497f7071 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 01:21:46 +0000 Subject: [PATCH] lilypond-1.5.18 --- make/mutopia-rules.make | 2 +- scripts/abc2ly.py | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/make/mutopia-rules.make b/make/mutopia-rules.make index d75f9197f2..08445758d5 100644 --- a/make/mutopia-rules.make +++ b/make/mutopia-rules.make @@ -21,7 +21,7 @@ $(outdir)/%.ly.txt: %.abc ln -f $< $@ $(outdir)/%.ly: %.abc - $(PYTHON) $(ABC2LY) -o $@ $< + $(PYTHON) $(ABC2LY) --strict -o $@ $< $(outdir)/%.dvi: $(outdir)/%.ly $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index b4295e933f..6428e0f105 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -67,6 +67,7 @@ import os UNDEF = 255 state = UNDEF +strict = 0 voice_idx_dict = {} header = {} header['footnotes'] = '' @@ -88,6 +89,13 @@ DIGITS='0123456789' alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ" HSPACE=' \t' midi_specs = '' + + +def error (msg): + sys.stderr.write (msg) + if strict: + sys.exit (1) + def check_clef(s): if not s: @@ -457,6 +465,7 @@ def compute_key (k): key_count = flat_key_seq.index (keytup) accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1)) else: + error ("Huh?") raise "Huh" key_table = [0] * 7 @@ -1226,8 +1235,7 @@ def parse_file (fn): ln = junk_space (ln) if ln: - msg = "%s: %d: Huh? Don't understand\n" % (fn, lineno) - sys.stderr.write (msg) + error ("%s: %d: Huh? Don't understand\n" % (fn, lineno)) left = orig_ln[0:-len (ln)] sys.stderr.write (left + '\n') sys.stderr.write (' ' * len (left) + ln + '\n') @@ -1246,7 +1254,8 @@ Options: -h, --help this help -o, --output=FILE set output filename to FILE -v, --version version information - + -s, --strict be strict about succes. + This program converts ABC music files (see http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) To LilyPond input. """ @@ -1256,7 +1265,7 @@ def print_version (): -(options, files) = getopt.getopt (sys.argv[1:], 'vo:h', ['help','version', 'output=']) +(options, files) = getopt.getopt (sys.argv[1:], 'vo:hs', ['help','version', 'output=', 'strict']) out_filename = '' for opt in options: @@ -1265,11 +1274,12 @@ for opt in options: if o== '--help' or o == '-h': help () sys.exit (0) - if o == '--version' or o == '-v': + elif o == '--version' or o == '-v': print_version () sys.exit(0) - - if o == '--output' or o == '-o': + elif o == '--strict' or o == '-s': + strict = 1 + elif o == '--output' or o == '-o': out_filename = a else: print o -- 2.39.5