Adding quiet mode to xmlImport
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index e7a851f..9d27880 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -312,7 +312,7 @@
writer.newline()
writer.newline()
- def importXML(self, file, progress=None):
+ def importXML(self, file, progress=None, quiet=None):
"""Import a TTX file (an XML-based text format), so as to recreate
a font object.
"""
@@ -323,7 +323,7 @@
# glyph names from (ie. 'post', 'cmap' or 'CFF ').
self.getGlyphOrder()
import xmlImport
- xmlImport.importXML(self, file, progress)
+ xmlImport.importXML(self, file, progress, quiet)
def isLoaded(self, tag):
"""Return true if the table identified by 'tag' has been
diff --git a/Lib/fontTools/ttLib/xmlImport.py b/Lib/fontTools/ttLib/xmlImport.py
index f110c8b..f53fb1b 100644
--- a/Lib/fontTools/ttLib/xmlImport.py
+++ b/Lib/fontTools/ttLib/xmlImport.py
@@ -11,10 +11,11 @@
class ExpatParser:
- def __init__(self, ttFont, fileName, progress=None):
+ def __init__(self, ttFont, fileName, progress=None, quiet=None):
self.ttFont = ttFont
self.fileName = fileName
self.progress = progress
+ self.quiet = quiet
self.root = None
self.contentStack = []
self.stackSize = 0
@@ -69,7 +70,8 @@
elif self.ttFont.verbose:
ttLib.debugmsg(msg)
else:
- print msg
+ if not self.quiet:
+ print msg
if tag == "GlyphOrder":
tableClass = ttLib.GlyphOrder
elif attrs.has_key("ERROR"):
@@ -123,13 +125,13 @@
print text
-def importXML(ttFont, fileName, progress=None):
+def importXML(ttFont, fileName, progress=None, quiet=None):
"""Import a TTX file (an XML-based text format), so as to recreate
a font object.
"""
if progress:
import stat
progress.set(0, os.stat(fileName)[stat.ST_SIZE] / 100 or 1)
- p = ExpatParser(ttFont, fileName, progress)
+ p = ExpatParser(ttFont, fileName, progress, quiet)
p.parse()
diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py
index c5cda86..18b05f1 100644
--- a/Lib/fontTools/ttx.py
+++ b/Lib/fontTools/ttx.py
@@ -208,11 +208,12 @@
def ttCompile(input, output, options):
- print 'Compiling "%s" to "%s"...' % (input, output)
+ if not options.quiet:
+ print 'Compiling "%s" to "%s"...' % (input, output)
ttf = TTFont(options.mergeFile,
recalcBBoxes=options.recalcBBoxes,
verbose=options.verbose, allowVID=options.allowVID)
- ttf.importXML(input)
+ ttf.importXML(input, quiet=options.quiet)
try:
ttf.save(output)
except OTLOffsetOverflowError, e: