Changeset 4113:90434cb52f2b in livinglogic.python.xist for src/ll/xist/scripts/dtd2xsc.py

Show
Ignore:
Timestamp:
09/23/10 15:34:22 (9 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Use argparse instead of optparse.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/scripts/dtd2xsc.py

    r4055 r4113  
    2525 
    2626 
    27 import sys, os.path, optparse 
     27import sys, os.path, argparse 
    2828 
    2929try: 
     
    169169 
    170170def main(args=None): 
    171     p = optparse.OptionParser(usage="usage: %prog [options] <input.dtd >output_xmlns.py") 
    172     p.add_option("-x", "--xmlns", dest="xmlns", help="the namespace name for this module") 
    173     p.add_option("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements?", choices=("none", "dupes", "all"), default="dupes") 
    174     p.add_option("-m", "--model", dest="model", default="once", help="Add sims information to the namespace", choices=("no", "all", "once")) 
    175     p.add_option("-d", "--defaults", action="store_true", dest="defaults", help="Output default values for attributes") 
     171    p = argparse.ArgumentParser(description="Convert DTD (on stdin) to XIST namespace (on stdout)") 
     172    p.add_argument("-x", "--xmlns", dest="xmlns", help="the namespace name for this module") 
     173    p.add_argument("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements?", choices=("none", "dupes", "all"), default="dupes") 
     174    p.add_argument("-m", "--model", dest="model", default="once", help="Add sims information to the namespace", choices=("no", "all", "once")) 
     175    p.add_argument("-d", "--defaults", action="store_true", dest="defaults", help="Output default values for attributes?") 
    176176 
    177     (options, args) = p.parse_args(args) 
    178     if len(args) != 0: 
    179         p.error("incorrect number of arguments") 
    180         return 1 
    181     print stream2xnd(sys.stdin, options.xmlns, options.shareattrs).aspy(model=options.model, defaults=options.defaults) 
     177    args = p.parse_args(args) 
     178    print stream2xnd(sys.stdin, options.xmlns, args.shareattrs).aspy(model=args.model, defaults=args.defaults) 
    182179 
    183180