Package schrodinger :: Package application :: Package desmond :: Package packages :: Module cui :: Class LazyParser
[hide private]
[frames] | no frames]

Class LazyParser

object --+
         |
        LazyParser

Some argument parsers are so slow, e.g., the msys parser. We should avoid running them unless they are really needed. For example, when user just wants to see the help, or when there is another parsing errors which interrupts the execution of the command, there is no need to run these slow parsers. We use this class to delay slow parsers' running.

Instance Methods [hide private]
 
__init__(self, parser)
x.__init__(...) initializes x; see help(type(x)) for signature
 
parse(self)
Calls the actual parser on the cached string and return the parsing result.
 
__call__(self, string)
Just caches the string to be parsed, and returns this LazyParser object itself.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parser)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • parser (Callable object) - It should take a string argument, parse the string, and return the resultant object.
Overrides: object.__init__

__call__(self, string)
(Call operator)

 

Just caches the string to be parsed, and returns this LazyParser object itself. The real parsing will be conducted when the parse method of this class is explicitly called.