From nobody Fri Mar 25 13:50:36 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A84051A3443A; Fri, 25 Mar 2022 13:50:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KQ3Q51Yh8z3h6S; Fri, 25 Mar 2022 13:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648216237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3ZjCB5cLr5rgsVlAK7svEzIM/bP7WYOTB1GDl8PhZ/M=; b=Npqsb+mSig8cdUFD9HZdZHXrA69A1PIKPJgtaChwecLt0Q1HlLdPtiEE823ULRCJozQvOH 8GjKnFFG7A6H5aOPUl/LXOIGEBJtxZG7EnYmzxqq20cbQanonN6Ug0GJmQYkPodCedQOUV 66I66Qi1ny+12euW6+lPBjjdGa7N1JHEDCzQjr2H/d+PcDqK+exzP5Z3DcWFO7obyJ6dQ0 RdsP1XL3lmIIk8zlC4bL8SoCJkHr6OQVR25QMgYuv1aQkyhj4MqAIbUo7sw0NS9UwxWlat O+iplmojkZB08dOSFTlMLq9ezmk7kKLYrEm6flTFUuisUtyCL2hZ5G1pT/maPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6449956B4; Fri, 25 Mar 2022 13:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22PDoanb037165; Fri, 25 Mar 2022 13:50:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22PDoaMp037164; Fri, 25 Mar 2022 13:50:36 GMT (envelope-from git) Date: Fri, 25 Mar 2022 13:50:36 GMT Message-Id: <202203251350.22PDoaMp037164@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Po-Chuan Hsieh Subject: git: d39785074bfd - main - math/py-svgmath: Fix build with setuptools 58.0.0+ List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sunpoet X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d39785074bfda73e954c242b1d930f4cea1e9f85 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648216237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3ZjCB5cLr5rgsVlAK7svEzIM/bP7WYOTB1GDl8PhZ/M=; b=hSjg1OirMCE+vxzYxja0abJeR2ix78UISUVPQzHkPhoQiyCc244evVLjwfrHhSSVKg6ACm wUp5o9bbmAuo38812LOgeOiFiG34IEjoNQ5+L0D27/ysyIkvT+EaLOGXGL7nYyYkNBEIIZ G7JinRWU82Qbtyh5bfyQ8YsHhRNGIB6Zuu2n/ZkSVkYSHtIunZ4YyHmWENTw1AUfvJNsAO hshP7iuKcGNS5Mdxbo3pZzm2XYtPb+6S4GVrBXQJhn1nVEc+dFDWBmxkGeyh/09Gv64heE fUlqcyTIi5WGfZPB3CXxc9d1pzQLDqd+3PKM0iv/0e/WRO1sqbqlODxEhcgzBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648216237; a=rsa-sha256; cv=none; b=hBxekkTxF03WFdtgDErztMIAQ6Aatb4RjeH94TVpquMGKc+9DwkddOzls6NQBZgTTNDRxw CgUZFAbKf1UfUoij46q3XXudTNobvjqdaHznYNZtk+/LEMSP+EdVT2iCF4SP/Y0UuT5mkR RtHqR9be3X9btvoUbJ59sdeOXgy15uOvudVFrvf7Evkq4WanGeqafwdUNGSyqJY34vaKy+ Z0ecz7u9g0B0pKZoLzlDN8yF83eAlvg9v5z4aTUso/VTXhAxSv5VTiudPuWLsYS0qU2LB+ VuEB+V2P7FEcZS5oNthfbkUqNm+IgScZxavSkyvhwCmthggLjpyRpIOLw4wGfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by sunpoet: URL: https://cgit.FreeBSD.org/ports/commit/?id=d39785074bfda73e954c242b1d930f4cea1e9f85 commit d39785074bfda73e954c242b1d930f4cea1e9f85 Author: Po-Chuan Hsieh AuthorDate: 2022-03-25 13:32:54 +0000 Commit: Po-Chuan Hsieh CommitDate: 2022-03-25 13:38:17 +0000 math/py-svgmath: Fix build with setuptools 58.0.0+ With hat: python --- math/py-svgmath/Makefile | 2 +- math/py-svgmath/files/patch-2to3 | 480 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 481 insertions(+), 1 deletion(-) diff --git a/math/py-svgmath/Makefile b/math/py-svgmath/Makefile index 12fdf68913aa..fe7cfa1de649 100644 --- a/math/py-svgmath/Makefile +++ b/math/py-svgmath/Makefile @@ -10,7 +10,7 @@ DISTNAME= SVGMath-${PORTVERSION} MAINTAINER= ports@FreeBSD.org COMMENT= MathML to SVG Converter in Python -USES= python:3.6+ +USES= dos2unix python:3.6+ USE_PYTHON= distutils autoplist .include diff --git a/math/py-svgmath/files/patch-2to3 b/math/py-svgmath/files/patch-2to3 new file mode 100644 index 000000000000..3dc7555e4f84 --- /dev/null +++ b/math/py-svgmath/files/patch-2to3 @@ -0,0 +1,480 @@ +--- svgmath/fonts/afm.py.orig 2022-03-18 18:47:45 UTC ++++ svgmath/fonts/afm.py +@@ -1,5 +1,5 @@ + import sys, glyphlist +-from metric import FontMetric, CharMetric, FontFormatError ++from .metric import FontMetric, CharMetric, FontFormatError + + def parseLength(s): return 0.001 * float(s) + +@@ -23,7 +23,7 @@ class AFMMetric (FontMetric): + def readFontMetrics(self, afmfile): + line = afmfile.readline() + if not line.startswith("StartFontMetrics"): +- raise AFMFormatError, "File is not an AFM file" ++ raise AFMFormatError("File is not an AFM file") + # TODO: AFM version control + + while True: +@@ -49,7 +49,7 @@ class AFMMetric (FontMetric): + elif tokens[0] == "Weight": + self.weight = tokens[1].strip() + elif tokens[0] == "FontBBox": +- self.bbox = map (parseLength, tokens[1].split()) ++ self.bbox = list(map (parseLength, tokens[1].split())) + elif tokens[0] == "CapHeight": + self.capheight = parseLength(tokens[1]) + elif tokens[0] == "XHeight": +@@ -88,7 +88,7 @@ class AFMMetric (FontMetric): + if d[0] == "W" or d[0] == "WX" or d[0] == "W0X": + width = parseLength(d[1]) + elif d[0] == "B" and len(d) == 5: +- bbox = map (parseLength, d[1:]) ++ bbox = list(map (parseLength, d[1:])) + elif d[0] == "N": + glyphname = d[1] + +@@ -137,6 +137,6 @@ def main(): + if len (sys.argv) == 2: + AFMMetric(sys.argv[1], log=sys.stderr).dump() + else: +- print """Usage: AFM.py """ ++ print("""Usage: AFM.py """) + + if __name__ == "__main__": main() +--- svgmath/fonts/glyphlist.py.orig 2022-03-18 18:47:45 UTC ++++ svgmath/fonts/glyphlist.py +@@ -15,13 +15,13 @@ class GlyphList(dict): + if len (codelist) != 1: continue # no support for compounds + codepoint = int (codelist[0], 16) + +- if glyph in self.keys(): ++ if glyph in list(self.keys()): + self[glyph].append(codepoint) + else: + self[glyph] = [codepoint] + + def lookup(self, glyphname): +- if glyphname in self.keys(): return self.get(glyphname) ++ if glyphname in list(self.keys()): return self.get(glyphname) + else: return defaultGlyphList.get(glyphname) + + +@@ -34,8 +34,8 @@ def main(): + else: + glyphList = defaultGlyphList + +- for entry, value in glyphList.items(): +- print entry, " => ", value ++ for entry, value in list(glyphList.items()): ++ print(entry, " => ", value) + + if __name__ == "__main__": + main() +--- svgmath/fonts/metric.py.orig 2022-03-18 18:47:45 UTC ++++ svgmath/fonts/metric.py +@@ -37,28 +37,28 @@ class FontMetric: + def postParse(self): + # Get Ascender from the 'd' glyph + if self.ascender is None: +- cm = self.chardata.get(ord(u'd')) ++ cm = self.chardata.get(ord('d')) + if cm is not None: + self.descender = cm.bbox[3] + else: self.ascender = 0.7 + + # Get Descender from the 'p' glyph + if self.descender is None: +- cm = self.chardata.get(ord(u'p')) ++ cm = self.chardata.get(ord('p')) + if cm is not None: + self.descender = cm.bbox[1] + else: self.descender = -0.2 + + # Get CapHeight from the 'H' glyph + if self.capheight is None: +- cm = self.chardata.get(ord(u'H')) ++ cm = self.chardata.get(ord('H')) + if cm is not None: + self.capheight = cm.bbox[3] + else: self.capheight = self.ascender + + # Get XHeight from the 'H' glyph + if self.xheight is None: +- cm = self.chardata.get(ord(u'x')) ++ cm = self.chardata.get(ord('x')) + if cm is not None: + self.xheight = cm.bbox[3] + else: self.xheight = 0.45 +@@ -69,7 +69,7 @@ class FontMetric: + # "equal", "minus", "plus", "less", "greater", "periodcentered") + # Default is CapHeight / 2, or 0.3 if there's no CapHeight. + if self.axisposition is None: +- for ch in [ord(u'+'), 0x2212, ord(u'='), ord(u'<'), ord(u'>'), 0xB7]: ++ for ch in [ord('+'), 0x2212, ord('='), ord('<'), ord('>'), 0xB7]: + cm = self.chardata.get(ch) + if cm is not None: + self.axisposition = (cm.bbox[1] + cm.bbox[3]) / 2 +@@ -80,7 +80,7 @@ class FontMetric: + if self.underlinethickness is not None: + self.rulewidth = self.underlinethickness + else: +- for ch in [0x2013, 0x2014, 0x2015, 0x2212, ord(u'-')]: ++ for ch in [0x2013, 0x2014, 0x2015, 0x2212, ord('-')]: + cm = self.chardata.get(ch) + if cm is not None: + self.rulewidth = cm.bbox[3] - cm.bbox[1] +@@ -107,35 +107,35 @@ class FontMetric: + else: self.vgap = self.rulewidth * 2 + + # Set missing glyph to be a space +- self.missingGlyph = self.chardata.get(ord(u' ')) or self.chardata.get(0xA0) ++ self.missingGlyph = self.chardata.get(ord(' ')) or self.chardata.get(0xA0) + + def dump(self): +- print "FontName: ", self.fontname +- print "FullName: ", self.fullname +- print "FontFamily: ", self.family +- print "Weight: ", self.weight +- print "FontBBox: ", ++ print("FontName: ", self.fontname) ++ print("FullName: ", self.fullname) ++ print("FontFamily: ", self.family) ++ print("Weight: ", self.weight) ++ print("FontBBox: ", end=' ') + for x in self.bbox: +- print x, +- print +- print "CapHeight: ", self.capheight +- print "XHeight: ", self.xheight +- print "Ascender: ", self.ascender +- print "Descender: ", self.descender +- print "StdHW: ", self.stdhw +- print "StdVW: ", self.stdvw +- print "UnderlinePosition: ", self.underlineposition +- print "UnderlineThickness: ", self.underlinethickness +- print "ItalicAngle: ", self.italicangle +- print "CharWidth: ", self.charwidth +- print "MathematicalBaseline: ", self.axisposition +- print "Character data: " +- chars = self.chardata.items() ++ print(x, end=' ') ++ print() ++ print("CapHeight: ", self.capheight) ++ print("XHeight: ", self.xheight) ++ print("Ascender: ", self.ascender) ++ print("Descender: ", self.descender) ++ print("StdHW: ", self.stdhw) ++ print("StdVW: ", self.stdvw) ++ print("UnderlinePosition: ", self.underlineposition) ++ print("UnderlineThickness: ", self.underlinethickness) ++ print("ItalicAngle: ", self.italicangle) ++ print("CharWidth: ", self.charwidth) ++ print("MathematicalBaseline: ", self.axisposition) ++ print("Character data: ") ++ chars = list(self.chardata.items()) + chars.sort(key = lambda c: c[0]) + for i, cm in chars: + if cm is None: continue +- print " ", ("U+%04X" % i), cm.name+":", " W", cm.width, " B", ++ print(" ", ("U+%04X" % i), cm.name+":", " W", cm.width, " B", end=' ') + for x in cm.bbox: +- print x, +- print ++ print(x, end=' ') ++ print() + +\ No newline at end of file +--- svgmath/fonts/ttf.py.orig 2022-03-18 18:47:45 UTC ++++ svgmath/fonts/ttf.py +@@ -1,5 +1,5 @@ + import sys +-from metric import FontMetric, CharMetric, FontFormatError ++from .metric import FontMetric, CharMetric, FontFormatError + + def readUnsigned(ff, size): + res = 0; +@@ -41,14 +41,14 @@ class TTFMetric (FontMetric): + + def readFontMetrics(self, ff): + version = ff.read(4) +- if map(ord, version) == [0, 1, 0, 0]: ++ if list(map(ord, version)) == [0, 1, 0, 0]: + self.fonttype="TTF" + elif version == "OTTO": + # self.fonttype="OTF" + # At the moment, I cannot parse bbox data out from CFF +- raise TTFFormatError, "OpenType/CFF fonts are unsupported" ++ raise TTFFormatError("OpenType/CFF fonts are unsupported") + else: +- raise TTFFormatError, "Not a TrueType file" ++ raise TTFFormatError("Not a TrueType file") + + numTables = readUnsigned(ff, 2) + tables = {} +@@ -61,15 +61,15 @@ class TTFMetric (FontMetric): + tables[tag] = (offset, length) + + def switchTable(tableTag): +- if tableTag not in tables.keys(): +- raise TTFFormatError, "Required table "+tableTag+" missing in TrueType file" ++ if tableTag not in list(tables.keys()): ++ raise TTFFormatError("Required table "+tableTag+" missing in TrueType file") + return tables[tableTag] + + (offset, length) = switchTable("head") + ff.seek(offset+12) + magic = readUnsigned(ff, 4) + if magic != 0x5F0F3CF5: +- raise TTFFormatError, "Magic number in 'head' table does not match the spec" ++ raise TTFFormatError("Magic number in 'head' table does not match the spec") + skip(ff, 2) + self.unitsPerEm = readUnsigned(ff, 2) + emScale = 1.0 / self.unitsPerEm +@@ -107,24 +107,24 @@ class TTFMetric (FontMetric): + nameOffset = readUnsigned(ff, 2) + + if platformID == 3 and encodingID == 1: +- if languageID in englishCodes or nameID not in uniNames.keys(): ++ if languageID in englishCodes or nameID not in list(uniNames.keys()): + uniNames[nameID] = (nameOffset, nameLength) + elif platformID == 1 and encodingID == 0: +- if languageID == 0 or nameID not in macNames.keys(): ++ if languageID == 0 or nameID not in list(macNames.keys()): + macNames[nameID] = (nameOffset, nameLength) + + def getName (code): +- if code in macNames.keys(): ++ if code in list(macNames.keys()): + (nameOffset, nameLength) = macNames[code] + ff.seek (storageOffset + nameOffset) + return ff.read(nameLength) + # FIXME: repair Mac encoding here +- elif code in uniNames.keys(): ++ elif code in list(uniNames.keys()): + (nameOffset, nameLength) = uniNames[code] + ff.seek (storageOffset + nameOffset) +- result = u"" ++ result = "" + for i in range (0, nameLength/2): +- result += unichr(readUnsigned(ff, 2)) ++ result += chr(readUnsigned(ff, 2)) + return result + + self.family = getName(1) +@@ -198,7 +198,7 @@ class TTFMetric (FontMetric): + encodingScheme = "Symbol" + subtableOffset = cmapEncodings.get((3, 0)) + if subtableOffset is None: +- raise TTFFormatError, "Cannot use font '%s': no known subtable in 'cmap' table" % self.fullname ++ raise TTFFormatError("Cannot use font '%s': no known subtable in 'cmap' table" % self.fullname) + else: + if self.log: + self.log.write("WARNING: font '%s' is a symbolic font - Unicode mapping may be unreliable\n" % self.fullname) +@@ -207,7 +207,7 @@ class TTFMetric (FontMetric): + + tableFormat = readUnsigned(ff, 2) + if tableFormat != 4: +- raise TTFFormatError, "Unsupported format in 'cmap' table: %d" % tableFormat ++ raise TTFFormatError("Unsupported format in 'cmap' table: %d" % tableFormat) + + subtableLength = readUnsigned(ff, 2) + skip (ff, 2) +@@ -264,7 +264,7 @@ class TTFMetric (FontMetric): + for i in range (0, self.numGlyphs+1): + glyphIndex.append(readUnsigned(ff, 4)) + else: +- raise TTFFormatError, "Invalid indexToLocFormat value (%d) in 'head' table" % str(self.indexToLocFormat) ++ raise TTFFormatError("Invalid indexToLocFormat value (%d) in 'head' table" % str(self.indexToLocFormat)) + + (offset, length) = switchTable("glyf") + for i in range (0, self.numGlyphs): +@@ -284,6 +284,6 @@ def main(): + if len (sys.argv) == 2: + TTFMetric(sys.argv[1], log=sys.stderr).dump() + else: +- print """Usage: TTF.py """ ++ print("""Usage: TTF.py """) + + if __name__ == "__main__": main() +--- svgmath/mathconfig.py.orig 2022-03-18 18:47:45 UTC ++++ svgmath/mathconfig.py +@@ -2,9 +2,9 @@ + + import os, sys + from xml import sax +-from fonts.afm import AFMMetric +-from fonts.ttf import TTFMetric +-from fonts.metric import FontFormatError ++from .fonts.afm import AFMMetric ++from .fonts.ttf import TTFMetric ++from .fonts.metric import FontFormatError + + class MathConfig(sax.ContentHandler): + """Configuration for MathML-to-SVG formatter. +@@ -26,47 +26,47 @@ class MathConfig(sax.ContentHandler): + parser.setContentHandler(self) + parser.setFeature(sax.handler.feature_namespaces, 0) + parser.parse(configfile) +- except sax.SAXException, xcpt: +- print "Error parsing configuration file ", configfile, ": ", xcpt.getMessage() ++ except sax.SAXException as xcpt: ++ print("Error parsing configuration file ", configfile, ": ", xcpt.getMessage()) + sys.exit(1) + + + def startElement(self, name, attributes): +- if name == u"config": +- self.verbose = (attributes.get(u"verbose") == u"true") +- self.debug = (attributes.get(u"debug", u"")).replace(u",", u" ").split() ++ if name == "config": ++ self.verbose = (attributes.get("verbose") == "true") ++ self.debug = (attributes.get("debug", "")).replace(",", " ").split() + +- elif name == u"defaults": ++ elif name == "defaults": + self.defaults.update(attributes) + +- elif name == u"fallback": +- familyattr = attributes.get(u"family", u"") +- self.fallbackFamilies = [" ".join(x.split()) for x in familyattr.split(u",")] ++ elif name == "fallback": ++ familyattr = attributes.get("family", "") ++ self.fallbackFamilies = [" ".join(x.split()) for x in familyattr.split(",")] + +- elif name == u"family": +- self.currentFamily = attributes.get(u"name", u"") ++ elif name == "family": ++ self.currentFamily = attributes.get("name", "") + self.currentFamily = "".join(self.currentFamily.lower().split()) + +- elif name == u"font": +- weight = attributes.get(u"weight", u"normal") +- style = attributes.get(u"style", u"normal") ++ elif name == "font": ++ weight = attributes.get("weight", "normal") ++ style = attributes.get("style", "normal") + fontfullname = self.currentFamily; +- if weight != u"normal": +- fontfullname += u" " + weight +- if style != u"normal": +- fontfullname += u" " + style ++ if weight != "normal": ++ fontfullname += " " + weight ++ if style != "normal": ++ fontfullname += " " + style + try: +- if u"afm" in attributes.keys(): +- fontpath = attributes.get(u"afm") +- metric = AFMMetric(fontpath, attributes.get(u"glyph-list"), sys.stderr) +- elif u"ttf" in attributes.keys(): +- fontpath = attributes.get(u"ttf") ++ if "afm" in list(attributes.keys()): ++ fontpath = attributes.get("afm") ++ metric = AFMMetric(fontpath, attributes.get("glyph-list"), sys.stderr) ++ elif "ttf" in list(attributes.keys()): ++ fontpath = attributes.get("ttf") + metric = TTFMetric(fontpath, sys.stderr) + else: + sys.stderr.write("Bad record in configuration file: font is neither AFM nor TTF\n") + sys.stderr.write("Font entry for '%s' ignored\n" % fontfullname) + return +- except FontFormatError, err: ++ except FontFormatError as err: + sys.stderr.write("Invalid or unsupported file format in '%s': %s\n" % (fontpath, err.message)) + sys.stderr.write("Font entry for '%s' ignored\n" % fontfullname) + return +@@ -76,41 +76,41 @@ class MathConfig(sax.ContentHandler): + sys.stderr.write("Font entry for '%s' ignored\n" % fontfullname) + return + +- self.fonts[weight+u" "+style+u" "+self.currentFamily] = metric ++ self.fonts[weight+" "+style+" "+self.currentFamily] = metric + +- elif name == u"mathvariant": +- variantattr = attributes.get(u"name") +- familyattr = attributes.get(u"family", "") +- splitFamily = [" ".join(x.split()) for x in familyattr.split(u",")] +- weightattr = attributes.get(u"weight", u"normal") +- styleattr = attributes.get(u"style", u"normal") ++ elif name == "mathvariant": ++ variantattr = attributes.get("name") ++ familyattr = attributes.get("family", "") ++ splitFamily = [" ".join(x.split()) for x in familyattr.split(",")] ++ weightattr = attributes.get("weight", "normal") ++ styleattr = attributes.get("style", "normal") + self.variants[variantattr] = (weightattr, styleattr, splitFamily) + +- elif name == u"operator-style": +- opname = attributes.get(u"operator") ++ elif name == "operator-style": ++ opname = attributes.get("operator") + if opname: + styling = {} + styling.update(attributes) +- del styling[u"operator"] ++ del styling["operator"] + self.opstyles[opname] = styling + else: + sys.stderr.write("Bad record in configuration file: operator-style with no operator attribute\n") + + + def endElement(self, name): +- if name == u"family": ++ if name == "family": + self.currentFamily = None + + + def findfont(self, weight, style, family): + """Finds a metric for family+weight+style.""" +- weight = (weight or u"normal").strip() +- style = (style or u"normal").strip() +- family = "".join((family or u"").lower().split()) ++ weight = (weight or "normal").strip() ++ style = (style or "normal").strip() ++ family = "".join((family or "").lower().split()) + +- for w in [weight, u"normal"]: +- for s in [style, u"normal"]: +- metric = self.fonts.get(w+u" "+s+u" "+family) ++ for w in [weight, "normal"]: ++ for s in [style, "normal"]: ++ metric = self.fonts.get(w+" "+s+" "+family) + if metric: return metric + return None + +@@ -121,20 +121,20 @@ def main(): + else: + config = MathConfig(sys.argv[1]) + +- print "Options: verbose =", config.verbose, " debug =", config.debug +- print "Fonts:" +- for (font, metric) in config.fonts.items(): +- print " ", font, "-->", metric.fontname +- print "Math variants:" +- for (variant, value) in config.variants.items(): +- print " ", variant, "-->", value +- print "Defaults:" +- for (attr, value) in config.defaults.items(): +- print " ", attr, "=", value +- print "Operator styling:" +- for (opname, value) in config.opstyles.items(): +- print " ", repr(opname), ":", value +- print "Fallback font families:", config.fallbackFamilies ++ print("Options: verbose =", config.verbose, " debug =", config.debug) ++ print("Fonts:") ++ for (font, metric) in list(config.fonts.items()): ++ print(" ", font, "-->", metric.fontname) ++ print("Math variants:") ++ for (variant, value) in list(config.variants.items()): ++ print(" ", variant, "-->", value) ++ print("Defaults:") ++ for (attr, value) in list(config.defaults.items()): ++ print(" ", attr, "=", value) ++ print("Operator styling:") ++ for (opname, value) in list(config.opstyles.items()): ++ print(" ", repr(opname), ":", value) ++ print("Fallback font families:", config.fallbackFamilies) + + + if __name__ == "__main__": main()