Changeset 426
- Timestamp:
- 05/20/07 03:44:34 (2 years ago)
- Files:
-
- cly/trunk/cly/everything.py (added)
- cly/trunk/cly/extra.py (added)
- cly/trunk/cly/__init__.py (modified) (5 diffs)
- cly/trunk/cly/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cly/trunk/cly/__init__.py
r425 r426 33 33 import re 34 34 import posixpath 35 import pydoc36 35 import string 37 import console38 36 39 37 __author__ = 'Alec Thomas <alec@swapoff.org>' … … 47 45 Help LazyHelp HelpParser Context Parser 48 46 49 static_candidates 47 quickstart 50 48 """.split() 51 49 … … 456 454 457 455 456 def annotate(*args, **kwargs): 457 def apply_annotation(function): 458 function.cly_args = args 459 function.cly_kwargs = kwargs 460 return function 461 return apply_annotation 462 463 458 464 class Group(Node): 459 465 """Group all children together at this location. … … 779 785 <two> Two 780 786 """ 787 import cly.console as console 788 781 789 if not self.help: 782 790 return … … 959 967 960 968 961 def static_candidates(*candidates): 962 """Convenience function to provide candidates matching a prefix. 963 964 Returns a callable that can be used directly with ``Node.candidates=``. 965 966 >>> static_candidates('foo', 'bar')(None, 'f') 967 ['foo '] 968 >>> parser = Parser(Grammar(node=Node('Test', candidates=static_candidates('foo', 'fuzz', 'bar')))) 969 >>> list(parser.parse('f').candidates()) 970 ['foo ', 'fuzz '] 971 """ 972 def cull_candidates(context, text): 973 return filter(None, [c + ' ' for c in candidates if c.startswith(text)]) 974 return cull_candidates 969 def quickstart(*grammar_or_callables, **interact_args): 970 """Start an interactive session from a grammar, or from inspecting a set of 971 callables.""" 972 from cly.extra import quickstart 973 quickstart(*grammar_or_callables, **interact_args) 975 974 976 975 cly/trunk/cly/test.py
r413 r426 10 10 import doctest 11 11 12 12 13 def suite(): 13 14 import cly 14 15 import cly.interactive 15 import cly. variables16 import cly.types 16 17 import cly.console 18 import cly.extra 17 19 18 20 suite = unittest.TestSuite() 19 21 suite.addTest(doctest.DocTestSuite(cly)) 20 22 suite.addTest(doctest.DocTestSuite(cly.interactive)) 21 suite.addTest(doctest.DocTestSuite(cly. variables))23 suite.addTest(doctest.DocTestSuite(cly.types)) 22 24 suite.addTest(doctest.DocTestSuite(cly.console)) 25 suite.addTest(doctest.DocTestSuite(cly.extra)) 23 26 24 27 return suite 25 28 29 26 30 if __name__ == '__main__': 27 31 unittest.main(defaultTest='suite')
