From 162043e3e3e456df8140243003b0c5a339bfdcec Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sun, 4 Oct 2009 20:01:27 -0400 Subject: [PATCH] freeze: add -o option for setting output file --- Demos/freeze/README.rst | 8 +++++++- bin/cython_freeze | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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] -- 2.26.2