From fdd073b82784902b91ac78567da5f56d71f4ceaf Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Mon, 31 Oct 2016 23:55:28 +0000 Subject: [PATCH] Convert remaining Python to Python3 and add +: support. --- abcfirstline.py | 12 ++++++------ abcrange.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/abcfirstline.py b/abcfirstline.py index ee06f21..f83a2c8 100755 --- a/abcfirstline.py +++ b/abcfirstline.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Write out a modified version of a .abc file with just the data # to print the first line of the music only. @@ -8,23 +8,23 @@ import sys def process(inf): continued = False - print "X:1" + print("X:1") for line in inf: line = line.strip() # If it is empty or starts "%", ignore it. if len(line) == 0 or line[0] == "%": continue - # Is it a header line? I.e. does it start LETTER COLON? + # Is it a header line? I.e. does it start LETTER (or +) COLON? # If so, output only ones we need. start = line[:2] - if len(start) > 1 and start[1] == ":" and start[0].isalpha(): + if len(start) > 1 and start[1] == ":" and (start[0].isalpha() or start[0] == '+'): if start[0] in ["M", "K", "L"]: - print line + print(line) # Output line. If it is a continuation, output at most one # continuation. else: - print line + print(line) if continued or line[-1] != "\\": break else: diff --git a/abcrange.py b/abcrange.py index 2c42e4f..834a579 100755 --- a/abcrange.py +++ b/abcrange.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Find the range of a tune. Do minimal parsing of an ABC input file # and print the lowest and highest notes therein. Accidentals are @@ -29,7 +29,7 @@ def process(filename, inf): # Is it a header line? I.e. does it start LETTER COLON? # If so, ignore. start = line[:2] - if len(start) > 1 and start[1] == ":" and start[0].isalpha(): + if len(start) > 1 and start[1] == ":" and (start[0].isalpha() or start[0] == '+'): continue # Tune line. @@ -82,7 +82,7 @@ def process(filename, inf): lowest = note note = 0 - print "{0}: {1} {2}".format(filename, highest, lowest) + print("{0}: {1} {2}".format(filename, highest, lowest)) if len(sys.argv) > 1: for arg in sys.argv[1:]: