From 0f293034749578d29494c2560c042c01ced50601 Mon Sep 17 00:00:00 2001 From: jvr Date: Sat, 11 May 2002 21:18:12 +0000 Subject: [PATCH] change how saveXML with splitTable=True works: it no longer creates a directory, and outputs a small file that references the individual table files git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@212 4cde692c-a291-49d1-8350-778aa11640f8 --- Lib/fontTools/ttLib/__init__.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py index 174411cfb..bc4274c83 100644 --- a/Lib/fontTools/ttLib/__init__.py +++ b/Lib/fontTools/ttLib/__init__.py @@ -42,7 +42,7 @@ Dumping 'prep' table... """ # -# $Id: __init__.py,v 1.23 2002-05-10 19:03:34 jvr Exp $ +# $Id: __init__.py,v 1.24 2002-05-11 21:18:12 jvr Exp $ # import os @@ -193,20 +193,25 @@ class TTFont: writer.newline() writer.newline() else: - # 'fileOrPath' must now be a path (pointing to a directory) - if not os.path.exists(fileOrPath): - os.mkdir(fileOrPath) - fileNameTemplate = os.path.join(fileOrPath, - os.path.basename(fileOrPath)) + ".%s.ttx" + # 'fileOrPath' must now be a path + path, ext = os.path.splitext(fileOrPath) + fileNameTemplate = path + ".%s" + ext + collection = xmlWriter.XMLWriter(fileOrPath) + collection.begintag("ttFont", sfntVersion=`self.sfntVersion`[1:-1], + ttLibVersion=version) + collection.newline() for i in range(numTables): tag = tables[i] + xmltag = tag2xmltag(tag) if splitTables: - writer = xmlWriter.XMLWriter(fileNameTemplate % tag2identifier(tag)) - writer.begintag("ttFont", sfntVersion=`self.sfntVersion`[1:-1], - ttLibVersion=version) + tablePath = fileNameTemplate % tag2identifier(tag) + writer = xmlWriter.XMLWriter(tablePath) + writer.begintag("ttFont", ttLibVersion=version) writer.newline() writer.newline() + collection.simpletag(xmltag, src=os.path.basename(tablePath)) + collection.newline() table = self[tag] report = "Dumping '%s' table..." % tag if progress: @@ -215,7 +220,6 @@ class TTFont: debugmsg(report) else: print report - xmltag = tag2xmltag(tag) if hasattr(table, "ERROR"): writer.begintag(xmltag, ERROR="decompilation error") else: @@ -238,6 +242,10 @@ class TTFont: writer.endtag("ttFont") writer.newline() writer.close() + else: + collection.endtag("ttFont") + collection.newline() + collection.close() if self.verbose: debugmsg("Done dumping TTX")