From: Mark Lodato Date: Mon, 5 Oct 2009 00:01:27 +0000 (-0400) Subject: freeze: add -o option for setting output file X-Git-Tag: 0.12.alpha0~30 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=162043e3e3e456df8140243003b0c5a339bfdcec;p=cython.git freeze: add -o option for setting output file --- diff --git a/Demos/freeze/README.rst b/Demos/freeze/README.rst index d2165a8f..9b97a8bd 100644 --- a/Demos/freeze/README.rst +++ b/Demos/freeze/README.rst @@ -7,7 +7,7 @@ cython_freeze - create a C file for embedding Cython modules SYNOPSIS ======== -cython_freeze module [...] +cython_freeze [-o outfile] module [...] DESCRIPTION @@ -28,6 +28,12 @@ simplicity. This module, on the other hand, can be used with multiple modules, but it requires another C source file to be created. +OPTIONS +======= + +-o FILE, --outfile=FILE write output to FILE instead of standard output + + EXAMPLE ======= diff --git a/bin/cython_freeze b/bin/cython_freeze index b2816304..b9441e4e 100755 --- a/bin/cython_freeze +++ b/bin/cython_freeze @@ -8,9 +8,11 @@ See Demos/freeze/README.rst for more details. import optparse -usage= '%prog module [module ...]' +usage= '%prog [-o outfile] module [module ...]' description = 'Create a C file for embedding Cython modules.' p = optparse.OptionParser(usage=usage, description=description) +p.add_option('-o', '--output', metavar='FILE', + help='write output to FILE instead of standard output') options, args = p.parse_args() @@ -18,6 +20,11 @@ if len(args) < 1: p.print_help() p.exit(1) +if options.output: + import sys + old_stdout = sys.stdout + sys.stdout = open(options.output, 'w') + def format_modname(name): if name.endswith('.pyx'): name = name[:-4]