changeset 2:d172c078f4a2

add -O option for specifying output file
author k0s <k0scist@gmail.com>
date Tue, 08 Dec 2009 16:23:50 -0500
parents 5627074cd79b
children 9e4da7517815
files martini/main.py setup.py
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/martini/main.py	Tue Dec 08 15:43:16 2009 -0500
+++ b/martini/main.py	Tue Dec 08 16:23:50 2009 -0500
@@ -5,6 +5,7 @@
 import config
 import os
 import sys
+from optparse import OptionParser
 
 sep = '--' # section separator
 
@@ -149,6 +150,11 @@
     # process arguments
     if args is None:
         args = sys.argv[1:]
+
+    parser = OptionParser()
+    parser.add_option('-O', dest='output',
+                      help="name of file to output (stdout if not specified)")
+    options, args = parser.parse_args(args)
     files, sections = parse_options(*args)
 
     # display usage information
@@ -161,7 +167,11 @@
     conf = list(files) 
     conf.append(sections)
     munger = config.ConfigMunger(*conf)
-    munger.write(sys.stdout)
+    if options.output:
+        fp = file(options.output, 'w')
+    else:
+        fp = sys.stdout
+    munger.write(fp)
  
 if __name__ == '__main__':
     set(sys.argv[1:])
--- a/setup.py	Tue Dec 08 15:43:16 2009 -0500
+++ b/setup.py	Tue Dec 08 16:23:50 2009 -0500
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.3'
+version = '0.3.1'
 
 setup(name='martINI',
       version=version,