Mercurial > dottes
changeset 587:1b79867b4f35
Convert remaining Python to Python3 and add +: support.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 31 Oct 2016 23:55:28 +0000 |
parents | daa3b76bd11f |
children | afc031477784 |
files | abcfirstline.py abcrange.py |
diffstat | 2 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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:
--- 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:]: