diff options
| author | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-07 03:02:18 +0000 |
|---|---|---|
| committer | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2002-12-07 03:02:18 +0000 |
| commit | e785b0053bb1ddb68b94a14c73d64321fc16adf7 (patch) | |
| tree | 43624bdcae72591a92834d63490d5b4b89b5401c /docutils/test/test_readers/test_python/showparse | |
| parent | 11bf869ee3e2e53fdbbb925a57cc2e8f95d48d97 (diff) | |
| download | docutils-e785b0053bb1ddb68b94a14c73d64321fc16adf7.tar.gz | |
added stdin input capability
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@1001 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_readers/test_python/showparse')
| -rwxr-xr-x | docutils/test/test_readers/test_python/showparse | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/docutils/test/test_readers/test_python/showparse b/docutils/test/test_readers/test_python/showparse index 61e08ba92..8144256d6 100755 --- a/docutils/test/test_readers/test_python/showparse +++ b/docutils/test/test_readers/test_python/showparse @@ -3,14 +3,17 @@ """ This is a tool for exploring abstract syntax trees generated by ``parser.suite()`` from test data in -docutils/test/test_readers/test_python/test_parser. +docutils/test/test_readers/test_python/test_parser or stdin. Usage:: showparse <key> <index> + showparse < <module.py> + Where ``<key>`` is the key to the ``totest`` dictionary, and ``<index>`` is -the index of the list ``totest[key]``. +the index of the list ``totest[key]``. If no arguments are given, stdin is +used for input. """ import sys @@ -32,9 +35,12 @@ def name_elements(ast): if type(node) == types.ListType: name_elements(node) -key, caseno = sys.argv[1:] -print 'totest["%s"][%s][0]:\n' % (key, caseno) -input_text = test_parser.totest[key][int(caseno)][0] +if len(sys.argv) > 1: + key, caseno = sys.argv[1:] + print 'totest["%s"][%s][0]:\n' % (key, caseno) + input_text = test_parser.totest[key][int(caseno)][0] +else: + input_text = sys.stdin.read() print input_text module = parser.suite(input_text) ast = parser.ast2list(module, line_info=1) |
