diff -r 377c84f956dc -r 193999e56a90 xmlChordAna.py --- a/xmlChordAna.py Tue May 26 11:43:51 2020 +0200 +++ b/xmlChordAna.py Thu Jun 08 09:40:19 2023 +0200 @@ -1,7 +1,7 @@ -#!/usr/bin/env python -# coding: latin-1 +#!/usr/bin/env python3 -import fractions, os, xml2b40 +import os, xml2b40 +import fractions as F import segLibB40 as S def keySeg (iseg,jseg): @@ -31,13 +31,14 @@ percnt = 100. * score / totNotes regels.append ('---- chord %s, score: %.0f%%' % (chord, percnt)) for tikken, noten in grpsInSeg: - noten = ', '.join ([S.b40nm (n) + str(n / 40) for n in noten]) - x = fractions.Fraction (tikken, tikkenPerKwart) - t = x.numerator / x.denominator + noten = ', '.join ([S.b40nm (n) + str(int (n / 40)) for n in noten]) + x = F.Fraction (tikken, tikkenPerKwart) + n, d = x.numerator, x.denominator + t = int (n / d) r = x - t if r == 0: r = '' regels.append ('%4d %3s %s' % (t, r, noten)) - return regels + return regels if __name__ == '__main__': from optparse import OptionParser @@ -53,4 +54,4 @@ noten = xml2b40.xml2b40 (fnmext, options.t, options.C5) regels = mkAna (noten, fnmext) - print '\n'.join (regels) + print ('\n'.join (regels))