From bc5e1cb195c0bfa1c8e7507326d5a9ad05aecb4b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Nov 2013 02:33:03 -0500 Subject: [PATCH] 2to3 --fix=has_key --- Lib/fontTools/afmLib.py | 8 ++--- Lib/fontTools/agl.py | 2 +- Lib/fontTools/cffLib.py | 10 +++--- Lib/fontTools/misc/sstruct.py | 4 +-- Lib/fontTools/misc/xmlReader.py | 4 +-- Lib/fontTools/ttLib/__init__.py | 40 +++++++++++----------- Lib/fontTools/ttLib/macUtils.py | 8 ++--- Lib/fontTools/ttLib/sfnt.py | 6 ++-- Lib/fontTools/ttLib/tables/C_O_L_R_.py | 6 ++-- Lib/fontTools/ttLib/tables/C_P_A_L_.py | 2 +- Lib/fontTools/ttLib/tables/T_S_I__1.py | 4 +-- Lib/fontTools/ttLib/tables/V_O_R_G_.py | 6 ++-- Lib/fontTools/ttLib/tables/_c_m_a_p.py | 8 ++--- Lib/fontTools/ttLib/tables/_g_l_y_f.py | 10 +++--- Lib/fontTools/ttLib/tables/_h_h_e_a.py | 2 +- Lib/fontTools/ttLib/tables/_k_e_r_n.py | 4 +-- Lib/fontTools/ttLib/tables/_m_a_x_p.py | 2 +- Lib/fontTools/ttLib/tables/_n_a_m_e.py | 2 +- Lib/fontTools/ttLib/tables/_p_o_s_t.py | 6 ++-- Lib/fontTools/ttLib/tables/_v_h_e_a.py | 2 +- Lib/fontTools/ttLib/tables/otBase.py | 6 ++-- Lib/fontTools/ttLib/tables/otConverters.py | 2 +- Lib/fontTools/ttLib/tables/otTables.py | 2 +- 23 files changed, 74 insertions(+), 72 deletions(-) diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py index aa303ad3f..528131ca6 100644 --- a/Lib/fontTools/afmLib.py +++ b/Lib/fontTools/afmLib.py @@ -208,7 +208,7 @@ class AFM: # a preferred order attrs = self._attrs for attr in preferredAttributeOrder: - if attrs.has_key(attr): + if attr in attrs: value = attrs[attr] if attr == "FontBBox": value = "%s %s %s %s" % value @@ -269,13 +269,13 @@ class AFM: writelines(path, lines, sep) def has_kernpair(self, pair): - return self._kerning.has_key(pair) + return pair in self._kerning def kernpairs(self): return self._kerning.keys() def has_char(self, char): - return self._chars.has_key(char) + return char in self._chars def chars(self): return self._chars.keys() @@ -290,7 +290,7 @@ class AFM: self._composites[glyphName] = components def __getattr__(self, attr): - if self._attrs.has_key(attr): + if attr in self._attrs: return self._attrs[attr] else: raise AttributeError, attr diff --git a/Lib/fontTools/agl.py b/Lib/fontTools/agl.py index c56ab81c9..a3ed28558 100644 --- a/Lib/fontTools/agl.py +++ b/Lib/fontTools/agl.py @@ -724,7 +724,7 @@ def _builddicts(): assert len(unicode) == 4 unicode = int(unicode, 16) glyphName = m.group(2) - if AGL2UV.has_key(glyphName): + if glyphName in AGL2UV: # the above table contains identical duplicates assert AGL2UV[glyphName] == unicode else: diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py index 54c9cf2c3..b876c502f 100644 --- a/Lib/fontTools/cffLib.py +++ b/Lib/fontTools/cffLib.py @@ -526,7 +526,7 @@ class CharStrings: return self.charStrings.values() def has_key(self, name): - return self.charStrings.has_key(name) + return name in self.charStrings def __len__(self): return len(self.charStrings) @@ -788,7 +788,7 @@ class CharsetConverter: if DEBUG: print " charset end at %s" % file.tell() else: # offset == 0 -> no charset data. - if isCID or not parent.rawDict.has_key("CharStrings"): + if isCID or "CharStrings" not in parent.rawDict: assert value == 0 # We get here only when processing fontDicts from the FDArray of CFF-CID fonts. Only the real topDict references the chrset. charset = None elif value == 0: @@ -992,7 +992,7 @@ class EncodingConverter(SimpleConverter): xmlWriter.newline() def xmlRead(self, (name, attrs, content), parent): - if attrs.has_key("name"): + if "name" in attrs: return attrs["name"] encoding = [".notdef"] * 256 for element in content: @@ -1613,9 +1613,9 @@ class IndexedStrings: def getSID(self, s): if not hasattr(self, "stringMapping"): self.buildStringMapping() - if cffStandardStringMapping.has_key(s): + if s in cffStandardStringMapping: SID = cffStandardStringMapping[s] - elif self.stringMapping.has_key(s): + elif s in self.stringMapping: SID = self.stringMapping[s] else: SID = len(self.strings) + cffStandardStringCount diff --git a/Lib/fontTools/misc/sstruct.py b/Lib/fontTools/misc/sstruct.py index 06899e155..c9ab7767f 100644 --- a/Lib/fontTools/misc/sstruct.py +++ b/Lib/fontTools/misc/sstruct.py @@ -67,7 +67,7 @@ def pack(format, object): object = object.__dict__ for name in names: value = object[name] - if fixes.has_key(name): + if name in fixes: # fixed point conversion value = int(round(value*fixes[name])) elements.append(value) @@ -86,7 +86,7 @@ def unpack(format, data, object=None): for i in range(len(names)): name = names[i] value = elements[i] - if fixes.has_key(name): + if name in fixes: # fixed point conversion value = value / fixes[name] dict[name] = value diff --git a/Lib/fontTools/misc/xmlReader.py b/Lib/fontTools/misc/xmlReader.py index f01dbcf4f..c9bbcd442 100644 --- a/Lib/fontTools/misc/xmlReader.py +++ b/Lib/fontTools/misc/xmlReader.py @@ -78,13 +78,13 @@ class XMLReader: print msg if tag == "GlyphOrder": tableClass = ttLib.GlyphOrder - elif attrs.has_key("ERROR"): + elif "ERROR" in attrs: tableClass = DefaultTable else: tableClass = ttLib.getTableClass(tag) if tableClass is None: tableClass = DefaultTable - if tag == 'loca' and self.ttFont.has_key(tag): + if tag == 'loca' and tag in self.ttFont: # Special-case the 'loca' table as we need the # original if the 'glyf' table isn't recompiled. self.currentTable = self.ttFont[tag] diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py index 54abed158..52d6d1a35 100644 --- a/Lib/fontTools/ttLib/__init__.py +++ b/Lib/fontTools/ttLib/__init__.py @@ -290,7 +290,7 @@ class TTFont: debugmsg("Done dumping TTX") def _tableToXML(self, writer, tag, progress, quiet): - if self.has_key(tag): + if tag in self: table = self[tag] report = "Dumping '%s' table..." % tag else: @@ -302,7 +302,7 @@ class TTFont: else: if not quiet: print report - if not self.has_key(tag): + if tag not in self: return xmlTag = tagToXML(tag) if hasattr(table, "ERROR"): @@ -322,7 +322,7 @@ class TTFont: """Import a TTX file (an XML-based text format), so as to recreate a font object. """ - if self.has_key("maxp") and self.has_key("post"): + if "maxp" in self and "post" in self: # Make sure the glyph order is loaded, as it otherwise gets # lost if the XML doesn't contain the glyph order, yet does # contain the table which was originally used to extract the @@ -337,12 +337,12 @@ class TTFont: def isLoaded(self, tag): """Return true if the table identified by 'tag' has been decompiled and loaded into memory.""" - return self.tables.has_key(tag) + return tag in self.tables def has_key(self, tag): if self.isLoaded(tag): return 1 - elif self.reader and self.reader.has_key(tag): + elif self.reader and tag in self.reader: return 1 elif tag == "GlyphOrder": return 1 @@ -407,11 +407,11 @@ class TTFont: self.tables[tag] = table def __delitem__(self, tag): - if not self.has_key(tag): + if tag not in self: raise KeyError, "'%s' table not found" % tag - if self.tables.has_key(tag): + if tag in self.tables: del self.tables[tag] - if self.reader and self.reader.has_key(tag): + if self.reader and tag in self.reader: del self.reader[tag] def setGlyphOrder(self, glyphOrder): @@ -422,10 +422,10 @@ class TTFont: return self.glyphOrder except AttributeError: pass - if self.has_key('CFF '): + if 'CFF ' in self: cff = self['CFF '] self.glyphOrder = cff.getGlyphOrder() - elif self.has_key('post'): + elif 'post' in self: # TrueType font glyphOrder = self['post'].getGlyphOrder() if glyphOrder is None: @@ -490,9 +490,9 @@ class TTFont: allNames = {} for i in range(numGlyphs): tempName = glyphOrder[i] - if reversecmap.has_key(tempName): + if tempName in reversecmap: unicode = reversecmap[tempName] - if agl.UV2AGL.has_key(unicode): + if unicode in agl.UV2AGL: # get name from the Adobe Glyph List glyphName = agl.UV2AGL[unicode] else: @@ -501,7 +501,7 @@ class TTFont: hex(unicode)[2:], 4)) tempName = glyphName n = 1 - while allNames.has_key(tempName): + while tempName in allNames: tempName = glyphName + "#" + `n` n = n + 1 glyphOrder[i] = tempName @@ -554,7 +554,7 @@ class TTFont: self._buildReverseGlyphOrderDict() glyphOrder = self.getGlyphOrder() d = self._reverseGlyphOrderDict - if not d.has_key(glyphName): + if glyphName not in d: if glyphName in glyphOrder: self._buildReverseGlyphOrderDict() return self.getGlyphID(glyphName) @@ -605,7 +605,7 @@ class TTFont: tableClass = getTableClass(tag) for masterTable in tableClass.dependencies: if masterTable not in done: - if self.has_key(masterTable): + if masterTable in self: self._writeTable(masterTable, writer, done) else: done.append(masterTable) @@ -622,7 +622,7 @@ class TTFont: if self.verbose: debugmsg("compiling '%s' table" % tag) return self.tables[tag].compile(self) - elif self.reader and self.reader.has_key(tag): + elif self.reader and tag in self.reader: if self.verbose: debugmsg("Reading '%s' table from disk" % tag) return self.reader[tag] @@ -641,11 +641,11 @@ class TTFont: If the font contains both a 'CFF ' and a 'glyf' table, you can use the 'preferCFF' argument to specify which one should be taken. """ - if preferCFF and self.has_key("CFF "): + if preferCFF and "CFF " in self: return self["CFF "].cff.values()[0].CharStrings - if self.has_key("glyf"): + if "glyf" in self: return _TTGlyphSet(self) - if self.has_key("CFF "): + if "CFF " in self: return self["CFF "].cff.values()[0].CharStrings raise TTLibError, "Font contains no outlines" @@ -667,7 +667,7 @@ class _TTGlyphSet: return self._ttFont["glyf"].keys() def has_key(self, glyphName): - return self._ttFont["glyf"].has_key(glyphName) + return glyphName in self._ttFont["glyf"] __contains__ = has_key diff --git a/Lib/fontTools/ttLib/macUtils.py b/Lib/fontTools/ttLib/macUtils.py index 2d5aedb52..27fb19ae8 100644 --- a/Lib/fontTools/ttLib/macUtils.py +++ b/Lib/fontTools/ttLib/macUtils.py @@ -172,20 +172,20 @@ class SFNTResourceWriter: names = {} for code, name in cmap.cmap.items(): names[name] = code - if self.ttFont.has_key('kern'): + if 'kern' in self.ttFont: kern = self.ttFont['kern'].getkern(0) if kern: fondkerning = [] for (left, right), value in kern.kernTable.items(): - if names.has_key(left) and names.has_key(right): + if left in names and right in names: fondkerning.append((names[left], names[right], scale * value)) fondkerning.sort() fond.kernTables = {0: fondkerning} - if self.ttFont.has_key('hmtx'): + if 'hmtx' in self.ttFont: hmtx = self.ttFont['hmtx'] fondwidths = [2048] * 256 + [0, 0] # default width, + plus two zeros. for name, (width, lsb) in hmtx.metrics.items(): - if names.has_key(name): + if name in names: fondwidths[names[name]] = scale * width fond.widthTables = {0: fondwidths} fond.save() diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py index 82e3e04e0..5ffc07717 100644 --- a/Lib/fontTools/ttLib/sfnt.py +++ b/Lib/fontTools/ttLib/sfnt.py @@ -68,7 +68,9 @@ class SFNTReader: self.flavorData = WOFFFlavorData(self) def has_key(self, tag): - return self.tables.has_key(tag) + return tag in self.tables + + __contains__ = has_key def keys(self): return self.tables.keys() @@ -132,7 +134,7 @@ class SFNTWriter: def __setitem__(self, tag, data): """Write raw table data to disk.""" reuse = False - if self.tables.has_key(tag): + if tag in self.tables: # We've written this table to file before. If the length # of the data is still the same, we allow overwriting it. entry = self.tables[tag] diff --git a/Lib/fontTools/ttLib/tables/C_O_L_R_.py b/Lib/fontTools/ttLib/tables/C_O_L_R_.py index b39a4a06a..c0f369153 100644 --- a/Lib/fontTools/ttLib/tables/C_O_L_R_.py +++ b/Lib/fontTools/ttLib/tables/C_O_L_R_.py @@ -114,7 +114,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable): layer.fromXML(element, ttFont) layers.append (layer) operator.setitem(self, glyphName, layers) - elif attrs.has_key("value"): + elif "value" in attrs: value = safeEval(attrs["value"]) setattr(self, name, value) @@ -124,7 +124,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable): # its a gid, convert to glyph name glyphSelector = self.getGlyphName(glyphSelector) - if not self.ColorLayers.has_key(glyphSelector): + if glyphSelector not in self.ColorLayers: return None return self.ColorLayers[glyphSelector] @@ -136,7 +136,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable): if value: self.ColorLayers[glyphSelector] = value - elif self.ColorLayers.has_key(glyphSelector): + elif glyphSelector in self.ColorLayers: del self.ColorLayers[glyphSelector] class LayerRecord: diff --git a/Lib/fontTools/ttLib/tables/C_P_A_L_.py b/Lib/fontTools/ttLib/tables/C_P_A_L_.py index 1e5a8783c..e9f6d1995 100644 --- a/Lib/fontTools/ttLib/tables/C_P_A_L_.py +++ b/Lib/fontTools/ttLib/tables/C_P_A_L_.py @@ -69,7 +69,7 @@ class table_C_P_A_L_(DefaultTable.DefaultTable): color.fromXML(element, ttFont) palette.append (color) self.palettes.append(palette) - elif attrs.has_key("value"): + elif "value" in attrs: value = safeEval(attrs["value"]) setattr(self, name, value) diff --git a/Lib/fontTools/ttLib/tables/T_S_I__1.py b/Lib/fontTools/ttLib/tables/T_S_I__1.py index fa6f7fe16..7572e2927 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__1.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__1.py @@ -48,7 +48,7 @@ class table_T_S_I__1(DefaultTable.DefaultTable): if len(data) % 2: data = data + "\015" # align on 2-byte boundaries, fill with return chars. Yum. name = glyphNames[i] - if self.glyphPrograms.has_key(name): + if name in self.glyphPrograms: text = self.glyphPrograms[name] else: text = "" @@ -65,7 +65,7 @@ class table_T_S_I__1(DefaultTable.DefaultTable): if len(data) % 2: data = data + "\015" # align on 2-byte boundaries, fill with return chars. code, name = codes[i] - if self.extraPrograms.has_key(name): + if name in self.extraPrograms: text = self.extraPrograms[name] else: text = "" diff --git a/Lib/fontTools/ttLib/tables/V_O_R_G_.py b/Lib/fontTools/ttLib/tables/V_O_R_G_.py index f817048c7..b8438f1bd 100644 --- a/Lib/fontTools/ttLib/tables/V_O_R_G_.py +++ b/Lib/fontTools/ttLib/tables/V_O_R_G_.py @@ -93,7 +93,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable): continue vOriginRec.fromXML(element, ttFont) self.VOriginRecords[vOriginRec.glyphName] = vOriginRec.vOrigin - elif attrs.has_key("value"): + elif "value" in attrs: value = safeEval(attrs["value"]) setattr(self, name, value) @@ -103,7 +103,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable): # its a gid, convert to glyph name glyphSelector = self.getGlyphName(glyphSelector) - if not self.VOriginRecords.has_key(glyphSelector): + if glyphSelector not in self.VOriginRecords: return self.defaultVertOriginY return self.VOriginRecords[glyphSelector] @@ -115,7 +115,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable): if value != self.defaultVertOriginY: self.VOriginRecords[glyphSelector] = value - elif self.VOriginRecords.has_key(glyphSelector): + elif glyphSelector in self.VOriginRecords: del self.VOriginRecords[glyphSelector] class VOriginRecord: diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index 9ae7987b8..6c86533ba 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -35,7 +35,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable): if not length: print "Error: cmap subtable is reported as having zero length: platformID %s, platEncID %s, format %s offset %s. Skipping table." % (platformID, platEncID,format, offset) continue - if not cmap_classes.has_key(format): + if format not in cmap_classes: table = cmap_format_unknown(format) else: table = cmap_classes[format](format) @@ -45,7 +45,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable): # any other data gets decompiled only when an attribute of the # subtable is referenced. table.decompileHeader(data[offset:offset+int(length)], ttFont) - if seenOffsets.has_key(offset): + if offset in seenOffsets: table.cmap = tables[seenOffsets[offset]].cmap else: seenOffsets[offset] = i @@ -64,7 +64,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable): offset = seen[id(table.cmap)] except KeyError: chunk = table.compile(ttFont) - if done.has_key(chunk): + if chunk in done: offset = done[chunk] else: offset = seen[id(table.cmap)] = done[chunk] = totalOffset + len(tableData) @@ -87,7 +87,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable): if not hasattr(self, "tables"): self.tables = [] format = safeEval(name[12:]) - if not cmap_classes.has_key(format): + if format not in cmap_classes: table = cmap_format_unknown(format) else: table = cmap_classes[format](format) diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 5ab69ce4d..c40614419 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -144,7 +144,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable): return self.glyphs.keys() def has_key(self, glyphName): - return self.glyphs.has_key(glyphName) + return glyphName in self.glyphs __contains__ = has_key @@ -864,23 +864,23 @@ class GlyphComponent: def fromXML(self, (name, attrs, content), ttFont): self.glyphName = attrs["glyphName"] - if attrs.has_key("firstPt"): + if "firstPt" in attrs: self.firstPt = safeEval(attrs["firstPt"]) self.secondPt = safeEval(attrs["secondPt"]) else: self.x = safeEval(attrs["x"]) self.y = safeEval(attrs["y"]) - if attrs.has_key("scale01"): + if "scale01" in attrs: scalex = safeEval(attrs["scalex"]) scale01 = safeEval(attrs["scale01"]) scale10 = safeEval(attrs["scale10"]) scaley = safeEval(attrs["scaley"]) self.transform = [[scalex, scale01], [scale10, scaley]] - elif attrs.has_key("scalex"): + elif "scalex" in attrs: scalex = safeEval(attrs["scalex"]) scaley = safeEval(attrs["scaley"]) self.transform = [[scalex, 0], [0, scaley]] - elif attrs.has_key("scale"): + elif "scale" in attrs: scale = safeEval(attrs["scale"]) self.transform = [[scale, 0], [0, scale]] self.flags = safeEval(attrs["flags"]) diff --git a/Lib/fontTools/ttLib/tables/_h_h_e_a.py b/Lib/fontTools/ttLib/tables/_h_h_e_a.py index cf2919ead..71c122142 100644 --- a/Lib/fontTools/ttLib/tables/_h_h_e_a.py +++ b/Lib/fontTools/ttLib/tables/_h_h_e_a.py @@ -39,7 +39,7 @@ class table__h_h_e_a(DefaultTable.DefaultTable): def recalc(self, ttFont): hmtxTable = ttFont['hmtx'] - if ttFont.has_key('glyf'): + if 'glyf' in ttFont: glyfTable = ttFont['glyf'] INFINITY = 100000 advanceWidthMax = 0 diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py index 22c5552d4..acb3b9576 100644 --- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py +++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py @@ -36,7 +36,7 @@ class table__k_e_r_n(DefaultTable.DefaultTable): else: version, length = struct.unpack(">HH", data[:4]) length = int(length) - if not kern_classes.has_key(version): + if version not in kern_classes: subtable = KernTable_format_unkown(version) else: subtable = kern_classes[version]() @@ -75,7 +75,7 @@ class table__k_e_r_n(DefaultTable.DefaultTable): if not hasattr(self, "kernTables"): self.kernTables = [] format = safeEval(attrs["format"]) - if not kern_classes.has_key(format): + if format not in kern_classes: subtable = KernTable_format_unkown(format) else: subtable = kern_classes[format]() diff --git a/Lib/fontTools/ttLib/tables/_m_a_x_p.py b/Lib/fontTools/ttLib/tables/_m_a_x_p.py index 5aafe9067..8c9905b05 100644 --- a/Lib/fontTools/ttLib/tables/_m_a_x_p.py +++ b/Lib/fontTools/ttLib/tables/_m_a_x_p.py @@ -38,7 +38,7 @@ class table__m_a_x_p(DefaultTable.DefaultTable): assert len(data) == 0 def compile(self, ttFont): - if ttFont.has_key('glyf'): + if 'glyf' in ttFont: if ttFont.isLoaded('glyf') and ttFont.recalcBBoxes: self.recalc(ttFont) else: diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py index 5234ae1ef..91abab452 100644 --- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py +++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py @@ -58,7 +58,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable): lastoffset = 0 done = {} # remember the data so we can reuse the "pointers" for name in self.names: - if done.has_key(name.string): + if name.string in done: name.offset, name.length = done[name.string] else: name.offset, name.length = done[name.string] = len(stringData), len(name.string) diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py index 82e91bc50..7c84c5052 100644 --- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py +++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py @@ -105,7 +105,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable): allNames = {} for i in range(ttFont['maxp'].numGlyphs): glyphName = psName = self.glyphOrder[i] - if allNames.has_key(glyphName): + if glyphName in allNames: # make up a new glyphName that's unique n = allNames[glyphName] allNames[glyphName] = n + 1 @@ -132,11 +132,11 @@ class table__p_o_s_t(DefaultTable.DefaultTable): extraDict[extraNames[i]] = i for glyphID in range(numGlyphs): glyphName = glyphOrder[glyphID] - if self.mapping.has_key(glyphName): + if glyphName in self.mapping: psName = self.mapping[glyphName] else: psName = glyphName - if extraDict.has_key(psName): + if psName in extraDict: index = 258 + extraDict[psName] elif psName in standardGlyphOrder: index = standardGlyphOrder.index(psName) diff --git a/Lib/fontTools/ttLib/tables/_v_h_e_a.py b/Lib/fontTools/ttLib/tables/_v_h_e_a.py index 9adc63b75..da0397c08 100644 --- a/Lib/fontTools/ttLib/tables/_v_h_e_a.py +++ b/Lib/fontTools/ttLib/tables/_v_h_e_a.py @@ -36,7 +36,7 @@ class table__v_h_e_a(DefaultTable.DefaultTable): def recalc(self, ttFont): vtmxTable = ttFont['vmtx'] - if ttFont.has_key('glyf'): + if 'glyf' in ttFont: if not ttFont.isLoaded('glyf'): return glyfTable = ttFont['glyf'] diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index 523d2c802..5c432b429 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -320,7 +320,7 @@ class OTTableWriter(object): item._doneWriting() else: item._doneWriting(internedTables) - if internedTables.has_key(item): + if item in internedTables: items[i] = item = internedTables[item] else: internedTables[item] = item @@ -359,7 +359,7 @@ class OTTableWriter(object): if hasattr(item, "name") and (item.name == "Coverage"): sortCoverageLast = 1 break - if not done.has_key(item): + if item not in done: item._gatherTables(tables, extTables, done) else: index = max(item.parent.keys()) @@ -380,7 +380,7 @@ class OTTableWriter(object): newDone = {} item._gatherTables(extTables, None, newDone) - elif not done.has_key(item): + elif item not in done: item._gatherTables(tables, extTables, done) else: index = max(item.parent.keys()) diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py index 0266c7198..36cb755dc 100644 --- a/Lib/fontTools/ttLib/tables/otConverters.py +++ b/Lib/fontTools/ttLib/tables/otConverters.py @@ -38,7 +38,7 @@ def buildConverters(tableSpec, tableNamespace): for cls in conv.featureParamTypes.values(): convertersByName[cls.__name__] = Table(name, repeat, aux, cls) converters.append(conv) - assert not convertersByName.has_key(name) + assert name not in convertersByName convertersByName[name] = conv return converters, convertersByName diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py index 584d0c5ec..6068c117f 100644 --- a/Lib/fontTools/ttLib/tables/otTables.py +++ b/Lib/fontTools/ttLib/tables/otTables.py @@ -662,7 +662,7 @@ def _buildClasses(): # XxxFormatN subtable, we only add the "base" table name = m.group(1) baseClass = FormatSwitchingBaseTable - if not namespace.has_key(name): + if name not in namespace: # the class doesn't exist yet, so the base implementation is used. cls = new.classobj(name, (baseClass,), {}) namespace[name] = cls