root/cly/trunk/doc/tutorial/tutorial4.py
| Revision 529, 291 bytes (checked in by athomas, 7 months ago) |
|---|
| Line | |
|---|---|
| 1 | import os |
| 2 | import sys |
| 3 | from cly import * |
| 4 | |
| 5 | def do_quit(): |
| 6 | sys.exit(0) |
| 7 | |
| 8 | def do_cat(files): |
| 9 | for file in files: |
| 10 | print open(os.path.expanduser(file)).read() |
| 11 | |
| 12 | grammar = XMLGrammar('tutorial4.xml') |
| 13 | interact(grammar, user_context={ |
| 14 | 'do_cat': do_cat, |
| 15 | 'do_quit': do_quit, |
| 16 | }) |
Note: See TracBrowser for help on using the browser.
