Implement writing output to arbitrary files including stdout.

Partially-fixes: http://sourceforge.net/p/fonttools/feature-requests/7/

git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@614 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
pabs3 2013-06-22 06:43:01 +00:00
parent 3ac875aa1d
commit fb37a24708
2 changed files with 15 additions and 2 deletions

View File

@ -67,6 +67,11 @@ Write the output files to directory
.Ar dir
instead of writing every output file to the same directory as the
corresponding input file.
.It Fl o Ar file
Write the output to
.Ar file
instead of writing it to the same directory as the
corresponding input file. Use - to write it to stdout.
.It Fl v
Be verbose. Write more messages to the standard output describing what
is being done.

View File

@ -15,6 +15,8 @@ usage: ttx [options] inputfile1 [... inputfileN]
-h Help: print this message
-d <outputfolder> Specify a directory where the output files are
to be created.
-o <outputfile> Specify a file to write the output to, use - for
standard output.
-v Verbose: more messages will be written to stdout about what
is being done.
-a allow virtual glyphs ID's on compile or decompile.
@ -88,6 +90,7 @@ class Options:
listTables = 0
outputDir = None
outputFile = None
verbose = 0
splitTables = 0
disassembleInstructions = 1
@ -110,6 +113,8 @@ class Options:
print "The -d option value must be an existing directory"
sys.exit(2)
self.outputDir = value
elif option == "-o":
self.outputFile = value
elif option == "-v":
self.verbose = 1
# dump options
@ -242,7 +247,7 @@ def guessFileType(fileName):
def parseOptions(args):
try:
rawOptions, files = getopt.getopt(args, "ld:vht:x:sim:baey:")
rawOptions, files = getopt.getopt(args, "ld:o:vht:x:sim:baey:")
except getopt.GetoptError:
usage()
@ -270,7 +275,10 @@ def parseOptions(args):
print 'Unknown file type: "%s"' % input
continue
output = makeOutputFileName(input, options.outputDir, extension)
if options.outputFile:
output = options.outputFile
else:
output = makeOutputFileName(input, options.outputDir, extension)
jobs.append((action, input, output))
return jobs, options