[4suite-checkins] In 4Suite/Ft/Xml/Lib, files _4xupdate.py

Jeremy Kloth jkloth at 4suite.org
Fri Aug 11 09:39:13 MDT 2006


Update of /var/local/cvsroot/4Suite/Ft/Xml/Lib
In directory dollar:/tmp/cvs-serv10601/Ft/Xml/Lib

Modified Files:
	_4xupdate.py 
Log Message:
Added main() class method to CommandLineApp (for script entry point)
Added '--version' as a global option for all applications
Moved project information to be per-application instead of hard-coded


ViewCVS diff:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/Lib/_4xupdate.py.diff?r1=1.15&r2=1.16
ViewCVS view:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/Lib/_4xupdate.py?rev=1.16&content-type=text/vnd.viewcvs-markup

Index: _4xupdate.py
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/Lib/_4xupdate.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- _4xupdate.py	16 Oct 2004 20:41:54 -0000	1.15
+++ _4xupdate.py	11 Aug 2006 15:39:13 -0000	1.16
@@ -12,17 +12,14 @@
 import sys, cStringIO
 
+from Ft import GetConfigVars
 from Ft.Lib import UriException, CloseStream
 from Ft.Lib.CommandLine.CommandLineUtil import SourceArgToInputSource
-from Ft.Xml import __version__
 from Ft.Xml import Domlette, XUpdate
 from Ft.Xml.InputSource import DefaultFactory
 
-__doc__ = """4XUpdate command-line application"""
-
-
 def Run(options, args):
 
-    out_file = options.has_key('out-file') \
-               and open(options['out-file'], 'wb') or sys.stdout
+    out_file = options.has_key('outfile') \
+               and open(options['outfile'], 'wb') or sys.stdout
 
     source_arg = args['source-uri']
@@ -72,18 +69,17 @@
 class XUpdateCommandLineApp(CommandLineApp.CommandLineApp):
 
+    project_name, project_version, project_url = \
+        GetConfigVars('NAME', 'VERSION', 'URL')
+
     def __init__(self):
         CommandLineApp.CommandLineApp.__init__(
             self,
             '4xupdate',
-            '4XUpdate version %s' % __version__,
-            __doc__,
+            'command-line tool for performing XUpdates on XML documents',
+            """4XUpdate command-line application""",
             [],
             ourOptions = Options.Options([
-                Options.Option('V',
-                               'version',
-                               'Display program version and exit',
-                               ),
                 Options.Option('o',
-                               'out-file=FILE',
+                               'outfile=FILE',
                                'Write the result to the given output file',
                                ),
@@ -103,13 +99,4 @@
             ]
 
-
-    def validate_options(self, options):
-        if options.has_key('version'):
-            print '4XUpdate, from 4Suite %s' % __version__
-            return
-        else:
-            return Command.Command.validate_options(self, options)
-
-
     def validate_arguments(self, args):
         msg = ''
@@ -122,5 +109,2 @@
         else:
             return Command.Command.validate_arguments(self, args)
-
-def Register():
-    return XUpdateCommandLineApp()



More information about the 4suite-checkins mailing list