Changeset 4434:f380ad46b3f2 in livinglogic.python.xist for src/ll/xist/scripts/dtd2xsc.py

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

dtd2xsc now supports reading from stdin too.

Files:
1 modified

Legend:

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

    r4430 r4434  
    1717 
    1818    ``urls`` 
    19         One or more URLs (or filenames) of DTDs to be parsed 
     19        Zerone or more URLs (or filenames) of DTDs to be parsed. If no URL is 
     20        given stdin will be read. 
    2021 
    2122    ``-x``, ``--xmlns`` 
     
    189190    ns = xnd.Module(**kwargs) 
    190191    with url.Context(): 
     192        if not urls: 
     193            urls = [sys.stdin] 
    191194        for u in urls: 
    192195            if isinstance(u, url.URL): 
     
    205208def main(args=None): 
    206209    p = argparse.ArgumentParser(description="Convert DTDs to XIST namespace (on stdout)") 
    207     p.add_argument("urls", metavar="urls", type=url.URL, help="ULRs of DTDs to be parsed", nargs="+") 
     210    p.add_argument("urls", metavar="urls", type=url.URL, help="Zero of more URLs of DTDs to be parsed (default stdin)", nargs="*") 
    208211    p.add_argument("-x", "--xmlns", dest="defaultxmlns", metavar="NAME", help="the namespace name for this module") 
    209212    p.add_argument("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements? (default: %(default)s)", choices=("none", "dupes", "all"), default="dupes")