# HG changeset patch # User Jim Hague # Date 1477958128 0 # Node ID 1b79867b4f35072337419bd3ab03917dfacad2c7 # Parent daa3b76bd11f068363c116913e5579091b19c709 Convert remaining Python to Python3 and add +: support. diff -r daa3b76bd11f -r 1b79867b4f35 abcfirstline.py --- a/abcfirstline.py Mon Oct 31 23:48:45 2016 +0000 +++ b/abcfirstline.py Mon Oct 31 23:55:28 2016 +0000 @@ -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 @@ 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 -r daa3b76bd11f -r 1b79867b4f35 abcrange.py --- a/abcrange.py Mon Oct 31 23:48:45 2016 +0000 +++ b/abcrange.py Mon Oct 31 23:55:28 2016 +0000 @@ -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 @@ # 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 @@ 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:]: