Changeset 4433:513c8e5bf375 in livinglogic.python.xist for src/ll/xist/scripts/xml2xsc.py

Show
Ignore:
Timestamp:
03/21/11 14:49:43 (8 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

xml2xsc reads stdin if no URL is given.

Files:
1 modified

Legend:

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

    r4432 r4433  
    2121 
    2222    ``urls`` 
    23         One or more URLs (or filenames) of XML files to be parsed 
     23        Zero or more URLs (or filenames) of XML files to be parsed. If no URL is 
     24        given stdin will be read. 
    2425 
    2526    ``-p``, ``--parser`` : ``etree`` or ``lxml`` 
     
    116117    ns = xnd.Module(defaultxmlns=defaultxmlns, model=model) 
    117118    with url.Context(): 
     119        if not urls: 
     120            urls = [sys.stdin] 
    118121        for u in urls: 
    119122            if isinstance(u, url.URL): 
     
    167170def main(args=None): 
    168171    p = argparse.ArgumentParser(description="Convert XML files to XIST namespace (on stdout)") 
    169     p.add_argument("urls", metavar="urls", type=url.URL, help="URLs of XML files to be parsed", nargs="+") 
     172    p.add_argument("urls", metavar="urls", type=url.URL, help="URLs of XML files to be parsed (default stdin)", nargs="*") 
    170173    p.add_argument("-p", "--parser", dest="parser", help="parser module to use for XML parsing (default: %(default)s)", choices=("etree", "lxml"), default="etree") 
    171174    p.add_argument("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements? (default: %(default)s)", choices=("none", "dupes", "all"), default="dupes")