[Erp5-report] r35582 nicolas - /erp5/trunk/utils/xupdate_processor/xupdate_processor/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon May 24 18:10:08 CEST 2010
Author: nicolas
Date: Mon May 24 18:10:04 2010
New Revision: 35582
URL: http://svn.erp5.org?rev=35582&view=rev
Log:
Use OptionParser to read arguments
Modified:
erp5/trunk/utils/xupdate_processor/xupdate_processor/__init__.py
Modified: erp5/trunk/utils/xupdate_processor/xupdate_processor/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/xupdate_processor/xupdate_processor/__init__.py?rev=35582&r1=35581&r2=35582&view=diff
==============================================================================
--- erp5/trunk/utils/xupdate_processor/xupdate_processor/__init__.py [utf8] (original)
+++ erp5/trunk/utils/xupdate_processor/xupdate_processor/__init__.py [utf8] Mon May 24 18:10:04 2010
@@ -3,9 +3,19 @@
from lxml import etree
def main():
- import sys
- doc_xml_name = sys.argv[1]
- xu_xml_name = sys.argv[2]
+ from optparse import OptionParser
+ usage = "usage: %prog xupdate_path document_path"
+ parser = OptionParser(usage=usage)
+
+ options, args = parser.parse_args()
+
+ if len(args) != 2:
+ print parser.print_help()
+ parser.error('incorrect number of arguments')
+
+ xu_xml_name = args[0]
+ doc_xml_name = args[1]
+
print etree.tostring(applyXUpdate(xml_xu_filename=xu_xml_name,
xml_doc_filename=doc_xml_name),
- pretty_print=True)
+ pretty_print=True)
More information about the Erp5-report
mailing list