Convert remaining Python to Python3 and add +: support.

This commit is contained in:
Jim Hague 2016-10-31 23:55:28 +00:00
parent fbd277f6c9
commit fdd073b827
2 changed files with 9 additions and 9 deletions

View File

@ -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:

View File

@ -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:]: